Autopsy  4.16.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
Installer.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2020 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.casemodule;
20 
21 import java.io.File;
22 import java.util.logging.Level;
23 import org.apache.commons.lang.StringUtils;
24 import org.openide.modules.ModuleInstall;
28 
32 public final class Installer extends ModuleInstall {
33 
34  private static final Logger logger = Logger.getLogger(Installer.class.getName());
35  private static final long serialVersionUID = 1L;
36 
37  private static Installer instance;
38 
39  public synchronized static Installer getDefault() {
40  if (instance == null) {
41  instance = new Installer();
42  }
43  return instance;
44  }
45 
46  private Installer() {
47  }
48 
49  @Override
50  public void restored() {
51  String tempDirStr = null;
52  try {
53  tempDirStr = UserPreferences.getAppTempDirectory();
54  if (StringUtils.isNotBlank(tempDirStr)) {
55  File tempDir = new File(tempDirStr);
56  if (tempDir.exists()) {
57  FileUtil.deleteDir(tempDir);
58  }
59  }
60  } catch (Exception ex) {
61  // This is a firewall exception should any issues occur
62  // during temp directory deletion
63  logger.log(Level.WARNING, "There was an error while cleaning up temp directory: " + (tempDirStr == null ? "<null>" : tempDirStr), ex);
64  }
65  }
66 }
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
static synchronized Installer getDefault()
Definition: Installer.java:39
static boolean deleteDir(File dirPath)
Definition: FileUtil.java:47

Copyright © 2012-2020 Basis Technology. Generated on: Tue Sep 22 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.