Private GIT

Skip to content
Snippets Groups Projects
Commit 1f7dc857 authored by Nic Wolfe's avatar Nic Wolfe
Browse files

Merged synology changes which keep the synology index updated if the notifier is selected

parents a0c14d2a 44c4d000
Branches
Tags
No related merge requests found
......@@ -35,9 +35,39 @@ class synoIndexNotifier:
def notify_download(self, ep_name):
pass
def update_library(self, ep_obj):
def moveFolder(self, old_path, new_path):
self.moveObject(old_path, new_path)
def moveFile(self, old_file, new_file):
self.moveObject(old_file, new_file)
def moveObject(self, old_path, new_path):
if sickbeard.USE_SYNOINDEX:
synoindex_cmd = ['/usr/syno/bin/synoindex', '-N', ek.ek(os.path.abspath, new_path), ek.ek(os.path.abspath, old_path)]
logger.log(u"Executing command "+str(synoindex_cmd))
logger.log(u"Absolute path to command: "+ek.ek(os.path.abspath, synoindex_cmd[0]), logger.DEBUG)
try:
p = subprocess.Popen(synoindex_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=sickbeard.PROG_DIR)
out, err = p.communicate() #@UnusedVariable
logger.log(u"Script result: "+str(out), logger.DEBUG)
except OSError, e:
logger.log(u"Unable to run synoindex: "+ex(e))
def deleteFolder(self, cur_path):
self.makeObject('-D', cur_path)
def addFolder(self, cur_path):
self.makeObject('-A', cur_path)
def deleteFile(self, cur_file):
self.makeObject('-d', cur_file)
def addFile(self, cur_file):
self.makeObject('-a', cur_file)
def makeObject(self, cmd_arg, cur_path):
if sickbeard.USE_SYNOINDEX:
synoindex_cmd = ['/usr/syno/bin/synoindex', '-a', ek.ek(os.path.abspath, ep_obj.location)]
synoindex_cmd = ['/usr/syno/bin/synoindex', cmd_arg, ek.ek(os.path.abspath, cur_path)]
logger.log(u"Executing command "+str(synoindex_cmd))
logger.log(u"Absolute path to command: "+ek.ek(os.path.abspath, synoindex_cmd[0]), logger.DEBUG)
try:
......
......@@ -184,6 +184,8 @@ class PostProcessor(object):
self._log(u"Deleting file "+cur_file, logger.DEBUG)
if ek.ek(os.path.isfile, cur_file):
ek.ek(os.remove, cur_file)
# do the library update for synoindex
notifiers.synoindex_notifier.deleteFile(cur_file)
def _combined_file_operation (self, file_path, new_path, new_base_name, associated_files=False, action=None):
"""
......@@ -763,6 +765,8 @@ class PostProcessor(object):
try:
ek.ek(os.mkdir, dest_path)
helpers.chmodAsParent(dest_path)
# do the library update for synoindex
notifiers.synoindex_notifier.addFolder(dest_path)
except OSError, IOError:
raise exceptions.PostProcessingFailed("Unable to create the episode's destination folder: "+dest_path)
......@@ -815,7 +819,7 @@ class PostProcessor(object):
notifiers.plex_notifier.update_library()
# do the library update for synoindex
notifiers.synoindex_notifier.update_library(ep_obj)
notifiers.synoindex_notifier.addFile(ep_obj.location)
# do the library update for trakt
notifiers.trakt_notifier.update_library(ep_obj)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment