added job resume file for completes
added contabo env place formatting only to output
This commit is contained in:
parent
a2663b9737
commit
21daae0340
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<groupId>tv.mangrana</groupId>
|
<groupId>tv.mangrana</groupId>
|
||||||
<artifactId>mangrana-commons</artifactId>
|
<artifactId>mangrana-commons</artifactId>
|
||||||
<version>3.0</version>
|
<version>3.1.1</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
|
|
@ -16,9 +16,9 @@ public class LocalEnvironmentManager {
|
||||||
|
|
||||||
public static final String REMOTE_ACCESS_FOLDER_FROM_MAC = "Volumes";
|
public static final String REMOTE_ACCESS_FOLDER_FROM_MAC = "Volumes";
|
||||||
|
|
||||||
public static void setLocalMode(String mode) {
|
public static void setLocalMode(LocalMode mode) {
|
||||||
try {
|
try {
|
||||||
LocalEnvironmentManager.mode = LocalMode.valueOf(mode);
|
LocalEnvironmentManager.mode = mode;
|
||||||
} catch (IllegalArgumentException ignored) {
|
} catch (IllegalArgumentException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import static tv.mangrana.config.LocalEnvironmentManager.getLocalMode;
|
||||||
import static tv.mangrana.jobs.JobFile.JobLocation;
|
import static tv.mangrana.jobs.JobFile.JobLocation;
|
||||||
import static tv.mangrana.jobs.JobFile.JobLocation.PATH_DOING;
|
import static tv.mangrana.jobs.JobFile.JobLocation.PATH_DOING;
|
||||||
import static tv.mangrana.jobs.JobFile.JobLocation.PATH_TODO;
|
import static tv.mangrana.jobs.JobFile.JobLocation.PATH_TODO;
|
||||||
import static tv.mangrana.utils.PathUtils.addSubFolder;
|
import static tv.mangrana.utils.PathUtils.addSubElement;
|
||||||
import static tv.mangrana.utils.PathUtils.rootFolder;
|
import static tv.mangrana.utils.PathUtils.rootFolder;
|
||||||
|
|
||||||
public class JobFileManager {
|
public class JobFileManager {
|
||||||
|
@ -25,6 +25,8 @@ public class JobFileManager {
|
||||||
static final String JOBS_FOLDER = "jobs";
|
static final String JOBS_FOLDER = "jobs";
|
||||||
static final String CONTABO_JOBS_FOLDER = "contabo_jobs";
|
static final String CONTABO_JOBS_FOLDER = "contabo_jobs";
|
||||||
|
|
||||||
|
static final String RESUME_FILE = "jobs.txt";
|
||||||
|
|
||||||
public enum JobFileType {
|
public enum JobFileType {
|
||||||
SONARR_JOBS("sonarr"),
|
SONARR_JOBS("sonarr"),
|
||||||
RADARR_JOBS("radarr"),
|
RADARR_JOBS("radarr"),
|
||||||
|
@ -65,11 +67,20 @@ public class JobFileManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getAbsolutePath(JobLocation location, JobFileType appType) {
|
public static String getAbsolutePath(JobLocation location, JobFileType appType) {
|
||||||
String jobsFolder = LocalEnvironmentManager.isLocal()
|
String jobsFolder = getJobsFolder();
|
||||||
? addSubFolder(rootFolder(LocalEnvironmentManager.getRootPath()), getLocalJobsFolder())
|
String appFolderPath = addSubElement(jobsFolder, appType.getFolderName());
|
||||||
|
return addSubElement(appFolderPath, location.getFolderName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getResumeFile() {
|
||||||
|
String jobsFolder = getJobsFolder();
|
||||||
|
return addSubElement(jobsFolder, RESUME_FILE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getJobsFolder() {
|
||||||
|
return LocalEnvironmentManager.isLocal()
|
||||||
|
? addSubElement(rootFolder(LocalEnvironmentManager.getRootPath()), getLocalJobsFolder())
|
||||||
: rootFolder(JOBS_FOLDER);
|
: rootFolder(JOBS_FOLDER);
|
||||||
String appFolderPath = addSubFolder(jobsFolder, appType.getFolderName());
|
|
||||||
return addSubFolder(appFolderPath, location.getFolderName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package tv.mangrana.utils;
|
package tv.mangrana.utils;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
@ -38,4 +40,9 @@ public class Output {
|
||||||
return MessageFormat.format(msg, params);
|
return MessageFormat.format(msg, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String formatTitle(String title, int length) {
|
||||||
|
return title.length() > length ? title.substring(0,length-3)+"..."
|
||||||
|
: StringUtils.rightPad(title.concat(" "), length, '.');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,11 +19,11 @@ public class PathUtils {
|
||||||
|
|
||||||
private PathUtils(){}
|
private PathUtils(){}
|
||||||
|
|
||||||
public static String addSubFolder(String parentFolder, String childFolder) {
|
public static String addSubElement(String parentFolder, String childFolder) {
|
||||||
return parentFolder+ SEPARATOR +childFolder;
|
return parentFolder+ SEPARATOR +childFolder;
|
||||||
}
|
}
|
||||||
public static String rootFolder(String rootFolderName){
|
public static String rootFolder(String rootFolderName){
|
||||||
return addSubFolder("",rootFolderName);
|
return addSubElement("",rootFolderName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getParentFromFullPath(String absolutePath){
|
public static String getParentFromFullPath(String absolutePath){
|
||||||
|
|
Loading…
Reference in New Issue