git://git.nikiroo.be
/
nikiroo-utils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5d19088
)
do not create covers/ dir in .
author
Niki Roo
<niki@nikiroo.be>
Sun, 3 May 2020 11:45:42 +0000
(13:45 +0200)
committer
Niki Roo
<niki@nikiroo.be>
Sun, 3 May 2020 11:45:42 +0000
(13:45 +0200)
Instance.java
patch
|
blob
|
blame
|
history
diff --git
a/Instance.java
b/Instance.java
index d0d1c84ab7643b65b34a91859a1b75ca59533091..5c00a0756e0aa2f484e2003135b9123d396257f0 100644
(file)
--- a/
Instance.java
+++ b/
Instance.java
@@
-147,10
+147,7
@@
public class Instance {
lib = createDefaultLibrary(remoteDir);
// create cache and TMP
lib = createDefaultLibrary(remoteDir);
// create cache and TMP
- File tmp = getFile(Config.CACHE_DIR, new File(configDir, "tmp"));
- if (!tmp.isAbsolute()) {
- tmp = new File(configDir, tmp.getPath());
- }
+ File tmp = getFile(Config.CACHE_DIR, configDir, "tmp");
Image.setTemporaryFilesRoot(new File(tmp.getParent(), "tmp.images"));
String ua = config.getString(Config.NETWORK_USER_AGENT, "");
Image.setTemporaryFilesRoot(new File(tmp.getParent(), "tmp.images"));
String ua = config.getString(Config.NETWORK_USER_AGENT, "");
@@
-166,9
+163,8
@@
public class Instance {
cache.setTraceHandler(tracer);
// readerTmp / coverDir
cache.setTraceHandler(tracer);
// readerTmp / coverDir
- readerTmp = getFile(UiConfig.CACHE_DIR_LOCAL_READER, new File(configDir, "tmp-reader"));
-
- coverDir = getFile(Config.DEFAULT_COVERS_DIR, new File(configDir, "covers"));
+ readerTmp = getFile(UiConfig.CACHE_DIR_LOCAL_READER, configDir, "tmp-reader");
+ coverDir = getFile(Config.DEFAULT_COVERS_DIR, configDir, "covers");
coverDir.mkdirs();
try {
coverDir.mkdirs();
try {
@@
-493,15
+489,12
@@
public class Instance {
} else {
String libDir = System.getenv("BOOKS_DIR");
if (libDir == null || libDir.isEmpty()) {
} else {
String libDir = System.getenv("BOOKS_DIR");
if (libDir == null || libDir.isEmpty()) {
- libDir = config.getString(Config.LIBRARY_DIR, "$HOME/Books");
- if (!getFile(libDir).isAbsolute()) {
- libDir = new File(configDir, libDir).getPath();
- }
+ libDir = getFile(Config.LIBRARY_DIR, configDir, "$HOME/Books").getPath();
}
try {
}
try {
- lib = new LocalLibrary(
get
File(libDir), config);
+ lib = new LocalLibrary(
new
File(libDir), config);
} catch (Exception e) {
} catch (Exception e) {
- tracer.error(new IOException("Cannot create library for directory: " +
getFile(libDir)
, e));
+ tracer.error(new IOException("Cannot create library for directory: " +
libDir
, e));
}
}
}
}
@@
-512,38
+505,43
@@
public class Instance {
* Return a path, but support the special $HOME variable.
*
* @param id the key for the path, which may contain "$HOME"
* Return a path, but support the special $HOME variable.
*
* @param id the key for the path, which may contain "$HOME"
- * @param def the default value if none
+ * @param configDir the directory to use as base if not absolute
+ * @param def the default value if none (will be configDir-rooted if needed)
* @return the path, with expanded "$HOME" if needed
*/
* @return the path, with expanded "$HOME" if needed
*/
- protected File getFile(Config id,
File
def) {
- String path = config.getString(id, def
.getPath()
);
- return getFile(path);
+ protected File getFile(Config id,
String configDir, String
def) {
+ String path = config.getString(id, def);
+ return getFile(path
, configDir
);
}
/**
* Return a path, but support the special $HOME variable.
*
* @param id the key for the path, which may contain "$HOME"
}
/**
* Return a path, but support the special $HOME variable.
*
* @param id the key for the path, which may contain "$HOME"
- * @param def the default value if none
+ * @param configDir the directory to use as base if not absolute
+ * @param def the default value if none (will be configDir-rooted if needed)
* @return the path, with expanded "$HOME" if needed
*/
* @return the path, with expanded "$HOME" if needed
*/
- protected File getFile(UiConfig id,
File
def) {
- String path = uiconfig.getString(id, def
.getPath()
);
- return getFile(path);
+ protected File getFile(UiConfig id,
String configDir, String
def) {
+ String path = uiconfig.getString(id, def);
+ return getFile(path
, configDir
);
}
/**
* Return a path, but support the special $HOME variable.
*
* @param path the path, which may contain "$HOME"
}
/**
* Return a path, but support the special $HOME variable.
*
* @param path the path, which may contain "$HOME"
+ * @param configDir the directory to use as base if not absolute
* @return the path, with expanded "$HOME" if needed
*/
* @return the path, with expanded "$HOME" if needed
*/
- protected File getFile(String path) {
+ protected File getFile(String path
, String configDir
) {
File file = null;
if (path != null && !path.isEmpty()) {
path = path.replace('/', File.separatorChar);
if (path.contains("$HOME")) {
path = path.replace("$HOME", getHome());
File file = null;
if (path != null && !path.isEmpty()) {
path = path.replace('/', File.separatorChar);
if (path.contains("$HOME")) {
path = path.replace("$HOME", getHome());
+ } else if (!path.startsWith("/")) {
+ path = new File(configDir, path).getPath();
}
file = new File(path);
}
file = new File(path);