Commit bdadba3f authored by TagForce's avatar TagForce
Browse files

Fixed verify_freespace check and return False on isFileLocked check

- verify_freespace will now log that a file is locked for access and
return True on the free space (would stop PP if a file could not be
read)
- isFileLocked will now return True if a file cannot be checked by
os.path.isfile()

Effectively logs a locked file correctly now when a file is locked for
either reading and/or writing.
parent 15659d70
......@@ -1520,7 +1520,7 @@ def verify_freespace(src, dest, oldfile=None):
if not ek.ek(os.path.isfile, src):
logger.log("A path to a file is required for the source. " + src + " is not a file.", logger.WARNING)
return False
return True
try:
diskfree = disk_usage(dest)
......@@ -1570,7 +1570,7 @@ def isFileLocked(file, writeLockCheck=False):
@param writeLockCheck: when true will check if the file is locked for writing (prevents move operations)
'''
if(not(os.path.exists(file))):
return False
return True
try:
f = open(file, 'r')
f.close()
......
......@@ -910,9 +910,13 @@ class PostProcessor(object):
logger.DEBUG)
# try to find out if we have enough space to perform the copy or move action.
if not verify_freespace(self.file_path, ek.ek(os.path.dirname, ep_obj.show._location), [ep_obj] + ep_obj.relatedEps):
self._log("Not enough space to continue PP, exiting")
return False
if not helpers.isFileLocked(self.file_path, False):
if not verify_freespace(self.file_path, ek.ek(os.path.dirname, ep_obj.show._location), [ep_obj] + ep_obj.relatedEps):
self._log("Not enough space to continue PP, exiting")
return False
else:
self._log("Unable to determine needed filespace as the source file is locked for access")
# delete the existing file (and company)
for cur_ep in [ep_obj] + ep_obj.relatedEps:
......@@ -1017,12 +1021,12 @@ class PostProcessor(object):
try:
# move the episode and associated files to the show dir
if self.process_method == "copy":
if isFileLocked(self.file_path, False):
if helpers.isFileLocked(self.file_path, False):
raise exceptions.PostProcessingFailed("File is locked for reading")
self._copy(self.file_path, dest_path, new_base_name, sickbeard.MOVE_ASSOCIATED_FILES,
sickbeard.USE_SUBTITLES and ep_obj.show.subtitles)
elif self.process_method == "move":
if isFileLocked(self.file_path, True):
if helpers.isFileLocked(self.file_path, True):
raise exceptions.PostProcessingFailed("File is locked for reading/writing")
self._move(self.file_path, dest_path, new_base_name, sickbeard.MOVE_ASSOCIATED_FILES,
sickbeard.USE_SUBTITLES and ep_obj.show.subtitles)
......@@ -1030,7 +1034,7 @@ class PostProcessor(object):
self._hardlink(self.file_path, dest_path, new_base_name, sickbeard.MOVE_ASSOCIATED_FILES,
sickbeard.USE_SUBTITLES and ep_obj.show.subtitles)
elif self.process_method == "symlink":
if isFileLocked(self.file_path, True):
if helpers.isFileLocked(self.file_path, True):
raise exceptions.PostProcessingFailed("File is locked for reading/writing")
self._moveAndSymlink(self.file_path, dest_path, new_base_name, sickbeard.MOVE_ASSOCIATED_FILES,
sickbeard.USE_SUBTITLES and ep_obj.show.subtitles)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment