1
0
mirror of https://github.com/mitb-archive/filebot synced 2025-03-09 22:09:47 -04:00

-DuseCreationDate=true

This commit is contained in:
Reinhard Pointner 2014-01-26 03:51:47 +00:00
parent 9574172b35
commit 6996914492
11 changed files with 79 additions and 106 deletions

View File

@ -15,6 +15,7 @@
# use NTFS extended attributes for storing metadata # use NTFS extended attributes for storing metadata
-DuseExtendedFileAttributes=true -DuseExtendedFileAttributes=true
-DuseCreationDate=true
# look for native libs here # look for native libs here
-Djna.library.path="%EXEDIR%" -Djna.library.path="%EXEDIR%"

View File

@ -19,6 +19,7 @@
# use NTFS extended attributes for storing metadata # use NTFS extended attributes for storing metadata
-DuseExtendedFileAttributes=true -DuseExtendedFileAttributes=true
-DuseCreationDate=true
# look for native libs here # look for native libs here
-Djna.library.path="%EXEDIR%" -Djna.library.path="%EXEDIR%"

View File

@ -23,6 +23,7 @@
# do not use NTFS extended attributes for storing metadata # do not use NTFS extended attributes for storing metadata
-DuseExtendedFileAttributes=false -DuseExtendedFileAttributes=false
-DuseCreationDate=false
# look for native libs here # look for native libs here
-Djna.library.path="%EXEDIR%" -Djna.library.path="%EXEDIR%"

View File

@ -17,6 +17,7 @@
# do not use NTFS extended attributes for storing metadata # do not use NTFS extended attributes for storing metadata
-DuseExtendedFileAttributes=false -DuseExtendedFileAttributes=false
-DuseCreationDate=false
# put all temporary files here # put all temporary files here
-Djava.io.tmpdir="%EXEDIR%\temp" -Djava.io.tmpdir="%EXEDIR%\temp"

View File

@ -156,6 +156,7 @@ public class Main {
} }
if (args.disableExtendedAttributes) { if (args.disableExtendedAttributes) {
System.setProperty("useExtendedFileAttributes", "false"); System.setProperty("useExtendedFileAttributes", "false");
System.setProperty("useCreationDate", "false");
} }
if (args.action.equalsIgnoreCase("test")) { if (args.action.equalsIgnoreCase("test")) {
System.setProperty("useExtendedFileAttributes", "false"); System.setProperty("useExtendedFileAttributes", "false");

View File

@ -1,7 +1,5 @@
package net.sourceforge.filebot; package net.sourceforge.filebot;
import static net.sourceforge.tuned.StringUtilities.*; import static net.sourceforge.tuned.StringUtilities.*;
import java.awt.GraphicsEnvironment; import java.awt.GraphicsEnvironment;
@ -17,19 +15,16 @@ import net.sourceforge.tuned.PreferencesMap;
import net.sourceforge.tuned.PreferencesMap.PreferencesEntry; import net.sourceforge.tuned.PreferencesMap.PreferencesEntry;
import net.sourceforge.tuned.PreferencesMap.StringAdapter; import net.sourceforge.tuned.PreferencesMap.StringAdapter;
public final class Settings { public final class Settings {
public static String getApplicationName() { public static String getApplicationName() {
return getApplicationProperty("application.name"); return getApplicationProperty("application.name");
} }
public static String getApplicationVersion() { public static String getApplicationVersion() {
return getApplicationProperty("application.version"); return getApplicationProperty("application.version");
} }
public static int getApplicationRevisionNumber() { public static int getApplicationRevisionNumber() {
try { try {
return Integer.parseInt(getApplicationProperty("application.revision")); return Integer.parseInt(getApplicationProperty("application.revision"));
@ -38,31 +33,29 @@ public final class Settings {
} }
} }
public static String getApplicationProperty(String key) { public static String getApplicationProperty(String key) {
return ResourceBundle.getBundle(Settings.class.getName(), Locale.ROOT).getString(key); return ResourceBundle.getBundle(Settings.class.getName(), Locale.ROOT).getString(key);
} }
public static boolean isUnixFS() { public static boolean isUnixFS() {
return Boolean.parseBoolean(System.getProperty("unixfs")); return Boolean.parseBoolean(System.getProperty("unixfs"));
} }
public static boolean useNativeShell() { public static boolean useNativeShell() {
return Boolean.parseBoolean(System.getProperty("useNativeShell")); return Boolean.parseBoolean(System.getProperty("useNativeShell"));
} }
public static boolean useGVFS() { public static boolean useGVFS() {
return Boolean.parseBoolean(System.getProperty("useGVFS")); return Boolean.parseBoolean(System.getProperty("useGVFS"));
} }
public static boolean useExtendedFileAttributes() { public static boolean useExtendedFileAttributes() {
return Boolean.parseBoolean(System.getProperty("useExtendedFileAttributes")); return Boolean.parseBoolean(System.getProperty("useExtendedFileAttributes"));
} }
public static boolean useCreationDate() {
return Boolean.parseBoolean(System.getProperty("useCreationDate"));
}
public static boolean useDonationReminder() { public static boolean useDonationReminder() {
String deployment = getApplicationDeployment(); String deployment = getApplicationDeployment();
@ -74,7 +67,6 @@ public final class Settings {
return true; return true;
} }
public static int getPreferredThreadPoolSize() { public static int getPreferredThreadPoolSize() {
try { try {
return Integer.parseInt(System.getProperty("threadPool")); return Integer.parseInt(System.getProperty("threadPool"));
@ -83,7 +75,6 @@ public final class Settings {
} }
} }
public static String getApplicationDeployment() { public static String getApplicationDeployment() {
String deployment = System.getProperty("application.deployment"); String deployment = System.getProperty("application.deployment");
if (deployment != null) if (deployment != null)
@ -95,7 +86,6 @@ public final class Settings {
return null; return null;
} }
public static File getApplicationFolder() { public static File getApplicationFolder() {
String applicationDirPath = System.getProperty("application.dir"); String applicationDirPath = System.getProperty("application.dir");
File applicationFolder = null; File applicationFolder = null;
@ -116,34 +106,28 @@ public final class Settings {
return applicationFolder; return applicationFolder;
} }
public static Settings forPackage(Class<?> type) { public static Settings forPackage(Class<?> type) {
return new Settings(Preferences.userNodeForPackage(type)); return new Settings(Preferences.userNodeForPackage(type));
} }
private final Preferences prefs; private final Preferences prefs;
private Settings(Preferences prefs) { private Settings(Preferences prefs) {
this.prefs = prefs; this.prefs = prefs;
} }
public Settings node(String nodeName) { public Settings node(String nodeName) {
return new Settings(prefs.node(nodeName)); return new Settings(prefs.node(nodeName));
} }
public String get(String key) { public String get(String key) {
return get(key, null); return get(key, null);
} }
public String get(String key, String def) { public String get(String key, String def) {
return prefs.get(key, def); return prefs.get(key, def);
} }
public void put(String key, String value) { public void put(String key, String value) {
if (value != null) { if (value != null) {
prefs.put(key, value); prefs.put(key, value);
@ -152,27 +136,22 @@ public final class Settings {
} }
} }
public void remove(String key) { public void remove(String key) {
prefs.remove(key); prefs.remove(key);
} }
public PreferencesEntry<String> entry(String key) { public PreferencesEntry<String> entry(String key) {
return new PreferencesEntry<String>(prefs, key, new StringAdapter()); return new PreferencesEntry<String>(prefs, key, new StringAdapter());
} }
public PreferencesMap<String> asMap() { public PreferencesMap<String> asMap() {
return PreferencesMap.map(prefs); return PreferencesMap.map(prefs);
} }
public PreferencesList<String> asList() { public PreferencesList<String> asList() {
return PreferencesList.map(prefs); return PreferencesList.map(prefs);
} }
public void clear() { public void clear() {
try { try {
// remove child nodes // remove child nodes
@ -187,12 +166,10 @@ public final class Settings {
} }
} }
public static String getApplicationIdentifier() { public static String getApplicationIdentifier() {
return joinBy(" ", getApplicationName(), getApplicationVersion(), String.format("(r%s)", getApplicationRevisionNumber())); return joinBy(" ", getApplicationName(), getApplicationVersion(), String.format("(r%s)", getApplicationRevisionNumber()));
} }
public static String getJavaRuntimeIdentifier() { public static String getJavaRuntimeIdentifier() {
String name = System.getProperty("java.runtime.name"); String name = System.getProperty("java.runtime.name");
String version = System.getProperty("java.version"); String version = System.getProperty("java.version");

View File

@ -609,7 +609,7 @@ public class CmdlineOperations implements CmdlineInterface {
} }
// write metadata into xattr if xattr is enabled // write metadata into xattr if xattr is enabled
if (matches != null && useExtendedFileAttributes()) { if (matches != null && (useExtendedFileAttributes() || useCreationDate())) {
try { try {
for (Match<File, ?> match : matches) { for (Match<File, ?> match : matches) {
File file = match.getValue(); File file = match.getValue();
@ -617,7 +617,7 @@ public class CmdlineOperations implements CmdlineInterface {
if (renameMap.containsKey(file) && meta != null) { if (renameMap.containsKey(file) && meta != null) {
File destination = resolveDestination(file, renameMap.get(file), false); File destination = resolveDestination(file, renameMap.get(file), false);
if (destination.isFile()) { if (destination.isFile()) {
MediaDetection.storeMetaInfo(destination, meta, file.getName()); MediaDetection.storeMetaInfo(destination, meta, file.getName(), useExtendedFileAttributes(), useCreationDate());
} }
} }
} }

View File

@ -3,7 +3,6 @@ package net.sourceforge.filebot.format;
import static java.util.Arrays.*; import static java.util.Arrays.*;
import static java.util.Collections.*; import static java.util.Collections.*;
import static net.sourceforge.filebot.MediaTypes.*; import static net.sourceforge.filebot.MediaTypes.*;
import static net.sourceforge.filebot.Settings.*;
import static net.sourceforge.filebot.format.Define.*; import static net.sourceforge.filebot.format.Define.*;
import static net.sourceforge.filebot.hash.VerificationUtilities.*; import static net.sourceforge.filebot.hash.VerificationUtilities.*;
import static net.sourceforge.filebot.media.MediaDetection.*; import static net.sourceforge.filebot.media.MediaDetection.*;
@ -358,13 +357,13 @@ public class MediaBindingBean {
} }
@Define("original") @Define("original")
public String getOriginalFileName() { public String getOriginalFileName() throws Exception {
return getOriginalFileName(mediaFile); return getOriginalFileName(mediaFile);
} }
@Define("xattr") @Define("xattr")
public Object getMetaAttributesObject() { public Object getMetaAttributesObject() throws Exception {
return getMetaAttributesObject(mediaFile); return new MetaAttributes(mediaFile).getObject();
} }
@Define("crc32") @Define("crc32")
@ -860,25 +859,11 @@ public class MediaBindingBean {
} }
private String getOriginalFileName(File file) { private String getOriginalFileName(File file) {
if (useExtendedFileAttributes()) {
try { try {
return new MetaAttributes(file).getOriginalName(); return new MetaAttributes(file).getOriginalName();
} catch (Throwable e) { } catch (Throwable e) {
// ignore
}
}
return null; return null;
} }
private Object getMetaAttributesObject(File file) {
if (useExtendedFileAttributes()) {
try {
return new MetaAttributes(file).getObject();
} catch (Throwable e) {
// ignore
}
}
return null;
} }
} }

View File

@ -1312,13 +1312,14 @@ public class MediaDetection {
} }
}; };
public static void storeMetaInfo(File file, Object model, String original) { public static void storeMetaInfo(File file, Object model, String original, boolean useExtendedFileAttributes, boolean useCreationDate) {
// only for Episode / Movie objects // only for Episode / Movie objects
if ((model instanceof Episode || model instanceof Movie) && file.exists()) { if ((useExtendedFileAttributes || useCreationDate) && (model instanceof Episode || model instanceof Movie) && file.isFile()) {
try { try {
MetaAttributes xattr = new MetaAttributes(file); MetaAttributes xattr = new MetaAttributes(file);
// set creation date to episode / movie release date // set creation date to episode / movie release date
if (useCreationDate) {
try { try {
if (model instanceof Episode) { if (model instanceof Episode) {
Episode episode = (Episode) model; Episode episode = (Episode) model;
@ -1334,8 +1335,10 @@ public class MediaDetection {
} catch (Exception e) { } catch (Exception e) {
Logger.getLogger(MediaDetection.class.getClass().getName()).warning("Failed to set creation date: " + e.getMessage()); Logger.getLogger(MediaDetection.class.getClass().getName()).warning("Failed to set creation date: " + e.getMessage());
} }
}
// store original name and model as xattr // store original name and model as xattr
if (useExtendedFileAttributes) {
try { try {
xattr.setObject(model); xattr.setObject(model);
if (xattr.getOriginalName() == null && original != null) { if (xattr.getOriginalName() == null && original != null) {
@ -1344,6 +1347,7 @@ public class MediaDetection {
} catch (Exception e) { } catch (Exception e) {
Logger.getLogger(MediaDetection.class.getClass().getName()).warning("Failed to set xattr: " + e.getMessage()); Logger.getLogger(MediaDetection.class.getClass().getName()).warning("Failed to set xattr: " + e.getMessage());
} }
}
} catch (Throwable t) { } catch (Throwable t) {
Logger.getLogger(MediaDetection.class.getClass().getName()).warning(t.toString()); Logger.getLogger(MediaDetection.class.getClass().getName()).warning(t.toString());
} }

View File

@ -115,7 +115,7 @@ class RenameAction extends AbstractAction {
} }
// write metadata into xattr if xattr is enabled // write metadata into xattr if xattr is enabled
if (useExtendedFileAttributes()) { if (useExtendedFileAttributes() || useCreationDate()) {
try { try {
for (Match<Object, File> match : matches) { for (Match<Object, File> match : matches) {
File file = match.getCandidate(); File file = match.getCandidate();
@ -123,7 +123,7 @@ class RenameAction extends AbstractAction {
if (renameMap.containsKey(file) && meta != null) { if (renameMap.containsKey(file) && meta != null) {
File destination = resolveDestination(file, renameMap.get(file), false); File destination = resolveDestination(file, renameMap.get(file), false);
if (destination.isFile()) { if (destination.isFile()) {
MediaDetection.storeMetaInfo(destination, meta, file.getName()); MediaDetection.storeMetaInfo(destination, meta, file.getName(), useExtendedFileAttributes(), useCreationDate());
} }
} }
} }

View File

@ -1284,6 +1284,7 @@ LeON
LEVERAGE LEVERAGE
LEViTY LEViTY
LF LF
LFF
LGLuX LGLuX
Lightmaker Lightmaker
lilwoodenboy lilwoodenboy
@ -2338,6 +2339,7 @@ x4subs
XanaX XanaX
xander xander
XC XC
Xell
XF XF
XiA XiA
XII XII