Compatibility fix

This commit is contained in:
Reinhard Pointner 2016-11-26 01:37:09 +08:00
parent 9af9706e4a
commit 94f5e5ade4
8 changed files with 11 additions and 14 deletions

View File

@ -21,7 +21,7 @@ public enum ApplicationFolder {
this.path = new File(path); this.path = new File(path);
} }
public File getFile() { public File get() {
return path; return path;
} }

View File

@ -66,11 +66,8 @@ public class CacheManager {
} }
private File acquireDiskStore() throws IOException { private File acquireDiskStore() throws IOException {
// prepare cache folder for this application instance
File cacheRoot = ApplicationFolder.Cache.getFile();
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
File cache = new File(cacheRoot, Integer.toString(i)); File cache = ApplicationFolder.Cache.resolve(String.valueOf(i));
// make sure cache is readable and writable // make sure cache is readable and writable
createFolders(cache); createFolders(cache);
@ -124,7 +121,7 @@ public class CacheManager {
} }
// serious error, abort // serious error, abort
throw new IOException("Unable to acquire cache lock: " + cacheRoot); throw new IOException("Unable to acquire cache lock: " + ApplicationFolder.Cache.get().getAbsolutePath());
} }
private static class ShutdownHook extends Thread { private static class ShutdownHook extends Thread {

View File

@ -91,7 +91,7 @@ public class Main {
// clear caches // clear caches
if (args.clearCache()) { if (args.clearCache()) {
log.info("Clear cache"); log.info("Clear cache");
for (File folder : getChildren(ApplicationFolder.Cache.getFile(), FOLDERS)) { for (File folder : getChildren(ApplicationFolder.Cache.get(), FOLDERS)) {
log.fine("* Delete " + folder); log.fine("* Delete " + folder);
delete(folder); delete(folder);
} }
@ -377,8 +377,8 @@ public class Main {
public static void initializeLogging(ArgumentBean args) throws IOException { public static void initializeLogging(ArgumentBean args) throws IOException {
// make sure that these folders exist // make sure that these folders exist
ApplicationFolder.TemporaryFiles.getFile().mkdirs(); ApplicationFolder.TemporaryFiles.get().mkdirs();
ApplicationFolder.AppData.getFile().mkdirs(); ApplicationFolder.AppData.get().mkdirs();
if (args.runCLI()) { if (args.runCLI()) {
// CLI logging settings // CLI logging settings

View File

@ -928,7 +928,7 @@ public class MediaBindingBean {
@Define("home") @Define("home")
public File getUserHome() { public File getUserHome() {
return ApplicationFolder.UserHome.getFile(); return ApplicationFolder.UserHome.get();
} }
@Define("output") @Define("output")

View File

@ -57,7 +57,7 @@ public class SecureCompiledScript extends CompiledScript {
// write permissions for cache and temp folders // write permissions for cache and temp folders
for (ApplicationFolder it : ApplicationFolder.values()) { for (ApplicationFolder it : ApplicationFolder.values()) {
permissions.add(new FilePermission(it.getFile().getAbsolutePath() + File.separator + "-", "read, write, delete")); permissions.add(new FilePermission(it.get().getAbsolutePath() + File.separator + "-", "read, write, delete"));
} }
return permissions; return permissions;

View File

@ -1012,7 +1012,7 @@ public class MediaDetection {
} }
public static boolean isStructureRoot(File folder) throws Exception { public static boolean isStructureRoot(File folder) throws Exception {
return isVolumeRoot(folder) || releaseInfo.getStructureRootPattern().matcher(folder.getName()).matches() || ApplicationFolder.UserHome.getFile().equals(folder.getParentFile()); return isVolumeRoot(folder) || releaseInfo.getStructureRootPattern().matcher(folder.getName()).matches() || ApplicationFolder.UserHome.get().equals(folder.getParentFile());
} }
public static File getStructureRoot(File file) throws Exception { public static File getStructureRoot(File file) throws Exception {

View File

@ -220,7 +220,7 @@ public class ReleaseInfo {
if (volumeRoots == null) { if (volumeRoots == null) {
Set<File> volumes = new HashSet<File>(); Set<File> volumes = new HashSet<File>();
File home = ApplicationFolder.UserHome.getFile(); File home = ApplicationFolder.UserHome.get();
List<File> roots = getFileSystemRoots(); List<File> roots = getFileSystemRoots();
// user root folder // user root folder

View File

@ -160,7 +160,7 @@ public class RenamePanel extends JComponent {
renameModel.useFormatter(FileInfo.class, new FileNameFormatter()); renameModel.useFormatter(FileInfo.class, new FileNameFormatter());
} }
RenameListCellRenderer cellrenderer = new RenameListCellRenderer(renameModel, ApplicationFolder.UserHome.getFile()); RenameListCellRenderer cellrenderer = new RenameListCellRenderer(renameModel, ApplicationFolder.UserHome.get());
namesList.getListComponent().setCellRenderer(cellrenderer); namesList.getListComponent().setCellRenderer(cellrenderer);
filesList.getListComponent().setCellRenderer(cellrenderer); filesList.getListComponent().setCellRenderer(cellrenderer);