forked from Github/Axter-Stash
FileMonitor ver 1.0.3
- Added start and stop FileMonitor button to Tools-UI FileMonitor Status - Fixed bug associated with starting FileMonitor service with no jobs waiting.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# FileMonitor: Ver 1.0.2 (By David Maisonave)
|
||||
# FileMonitor: Ver 1.0.3 (By David Maisonave)
|
||||
|
||||
FileMonitor is a [Stash](https://github.com/stashapp/stash) plugin with the following two main features:
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
const { Link, NavLink, } = PluginApi.libraries.ReactRouterDOM;
|
||||
var iconToUse = faFileCircleXmark;
|
||||
var FileMonitorRunningStatusStr = "";
|
||||
var StartOrStop_FileMonitorButton = null;
|
||||
var DockerWarning = null;
|
||||
function RunPluginFileMonitor(Mode, ActionID = 0, DataType = "text", Async = false) {
|
||||
console.log("Mode = " + Mode);
|
||||
@@ -29,10 +30,12 @@
|
||||
if (result.indexOf("FileMonitorStatus:'RUNNING'") > 0){
|
||||
iconToUse = faFileCircleCheck;
|
||||
FileMonitorRunningStatusStr = "FileMonitor is RUNNING...";
|
||||
StartOrStop_FileMonitorButton = React.createElement(Link, { to: "/FileMonitor_Stop", title: "Stops library monitoring within 2 minutes." }, React.createElement(Button, null, "Stop Library Monitor"));
|
||||
}
|
||||
else {
|
||||
iconToUse = faFileCircleXmark;
|
||||
FileMonitorRunningStatusStr = "FileMonitor is NOT running!!!";
|
||||
StartOrStop_FileMonitorButton = React.createElement(Link, { to: "/FileMonitor_Start", title: "Run FileMonitor as a SERVICE to update Stash with any media file changes." }, React.createElement(Button, null, "Start Library Monitor Service"));
|
||||
}
|
||||
if (result.indexOf("IS_DOCKER:'True'") > 0){
|
||||
DockerWarning = React.createElement("div", null,
|
||||
@@ -66,7 +69,9 @@
|
||||
});
|
||||
}
|
||||
RunPluginFileMonitor("getFileMonitorRunningStatus");
|
||||
const HomePage = () => {
|
||||
function DisplayFileMonitorRunningStatus(PreCmd = null) {
|
||||
if (PreCmd != null)
|
||||
RunPluginFileMonitor(PreCmd);
|
||||
RunPluginFileMonitor("getFileMonitorRunningStatus", 1);
|
||||
console.log("FileMonitorRunningStatusStr = " + FileMonitorRunningStatusStr);
|
||||
var MyHeader = React.createElement("h1", null, "FileMonitor Running Status Page");
|
||||
@@ -75,10 +80,22 @@
|
||||
React.createElement("p", null),
|
||||
React.createElement("p", null),
|
||||
React.createElement("h4", null, FileMonitorRunningStatusStr),
|
||||
DockerWarning
|
||||
DockerWarning,
|
||||
StartOrStop_FileMonitorButton
|
||||
));
|
||||
}
|
||||
const HomePage = () => {
|
||||
return DisplayFileMonitorRunningStatus();
|
||||
};
|
||||
const FileMonitor_Start = () => {
|
||||
return DisplayFileMonitorRunningStatus("start_library_monitor_service_json");
|
||||
};
|
||||
const FileMonitor_Stop = () => {
|
||||
return DisplayFileMonitorRunningStatus("stop_library_monitor_json");
|
||||
};
|
||||
PluginApi.register.route("/FileMonitor", HomePage);
|
||||
PluginApi.register.route("/FileMonitor_Start", FileMonitor_Start);
|
||||
PluginApi.register.route("/FileMonitor_Stop", FileMonitor_Stop);
|
||||
PluginApi.patch.before("SettingsToolsSection", function (props) {
|
||||
const { Setting, } = PluginApi.components;
|
||||
return [
|
||||
|
||||
@@ -65,11 +65,15 @@ stash = StashPluginHelper(
|
||||
apiKey=parse_args.apikey
|
||||
)
|
||||
|
||||
doJsonReturnModeTypes = ["getFileMonitorRunningStatus"]
|
||||
doJsonReturnModeTypes = ["getFileMonitorRunningStatus", "start_library_monitor_service_json", "stop_library_monitor_json"]
|
||||
doJsonReturn = False
|
||||
doJsonReturnFileMonitorStatus = False
|
||||
if len(sys.argv) < 2 and stash.PLUGIN_TASK_NAME in doJsonReturnModeTypes:
|
||||
doJsonReturn = True
|
||||
doJsonReturnFileMonitorStatus = True
|
||||
stash.log_to_norm = stash.LogTo.FILE
|
||||
if stash.PLUGIN_TASK_NAME.endswith("_json"):
|
||||
stash.PLUGIN_TASK_NAME = stash.PLUGIN_TASK_NAME[:-5]
|
||||
|
||||
stash.status(logLevel=logging.DEBUG)
|
||||
stash.Log(f"\nStarting (__file__={__file__}) (stash.CALLED_AS_STASH_PLUGIN={stash.CALLED_AS_STASH_PLUGIN}) (stash.DEBUG_TRACING={stash.DEBUG_TRACING}) (stash.DRY_RUN={stash.DRY_RUN}) (stash.PLUGIN_TASK_NAME={stash.PLUGIN_TASK_NAME})************************************************")
|
||||
@@ -213,6 +217,8 @@ def isJobWaitingToRun(getJobIdOf_StartAsAServiceTask = False):
|
||||
FileMonitorPluginIsOnTaskQue = False
|
||||
jobIsWaiting = False
|
||||
taskQue = stash.job_queue()
|
||||
if taskQue == None:
|
||||
return jobIsWaiting
|
||||
for jobDetails in taskQue:
|
||||
stash.Trace(f"(Job ID({jobDetails['id']})={jobDetails})")
|
||||
if getJobIdOf_StartAsAServiceTask:
|
||||
@@ -882,6 +888,8 @@ def stop_library_monitor():
|
||||
stash.Trace(f"Shared memory map opended, and flag set to {shm_buffer[0]}")
|
||||
shm_a.close()
|
||||
shm_a.unlink() # Call unlink only once to release the shared memory
|
||||
if doJsonReturnFileMonitorStatus:
|
||||
sys.stdout.write("{" + f"{stash.PLUGIN_TASK_NAME} : 'complete', FileMonitorStatus:'NOT running', IS_DOCKER:'{stash.IS_DOCKER}'" + "}")
|
||||
|
||||
def start_library_monitor_service():
|
||||
# First check if FileMonitor is already running
|
||||
@@ -901,6 +909,9 @@ def start_library_monitor_service():
|
||||
args += ["-a", stash.API_KEY]
|
||||
results = stash.executePythonScript(args)
|
||||
stash.Trace(f"executePythonScript results='{results}'")
|
||||
if doJsonReturnFileMonitorStatus:
|
||||
time.sleep(5)
|
||||
sys.stdout.write("{" + f"{stash.PLUGIN_TASK_NAME} : 'complete', FileMonitorStatus:'RUNNING', IS_DOCKER:'{stash.IS_DOCKER}'" + "}")
|
||||
|
||||
def synchronize_library(removeScene=False):
|
||||
stash.startSpinningProcessBar()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
name: FileMonitor
|
||||
description: Monitors the Stash library folders, and updates Stash if any changes occurs in the Stash library paths.
|
||||
version: 1.0.2
|
||||
version: 1.0.3
|
||||
url: https://github.com/David-Maisonave/Axter-Stash/tree/main/plugins/FileMonitor
|
||||
ui:
|
||||
javascript:
|
||||
|
||||
@@ -5,4 +5,7 @@
|
||||
### 1.0.1
|
||||
- Added Docker support.
|
||||
### 1.0.2
|
||||
- Added ability to monitor host file system for multiple Docker Stash installations.
|
||||
- Added ability to monitor host file system for multiple Docker Stash installations.
|
||||
### 1.0.3
|
||||
- Added start and stop FileMonitor button to Tools-UI FileMonitor Status
|
||||
- Fixed bug associated with starting FileMonitor service with no jobs waiting.
|
||||
Reference in New Issue
Block a user