Skip to content

Commit

Permalink
v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mgutierrezp committed Mar 26, 2014
1 parent 781fa35 commit e9e7d7b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,4 @@ COPYING
CHANGELOG

v1.0 - 2014/03/17 - first version. Bugs will come soon :-)
v1.1 - 2014/03/26 - bug fix
20 changes: 10 additions & 10 deletions checkExpiredFiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,19 +324,19 @@ def applyChanges(filesDict):

print("Applying changes...")

print("Removing expired files from filesystem... ",end="")
print("Removing expired files from filesystem (if any)... ",end="")
try:
for file in filesDict:
if filesDict[file]["status"]=="expired":
for ffile in filesDict:
if filesDict[ffile]["status"]=="expired":
# file has expired
fileToDeleteFull=os.path.join(DIRTOSCAN,file)
fileToDeleteRelative=file
fileToDeleteFull=os.path.join(DIRTOSCAN,ffile)
fileToDeleteRelative=ffile
if not os.path.exists(fileToDeleteFull) and not os.path.islink(fileToDeleteFull):
_error("File does not exists anymore, skipping: "+fileToRelative)
break
_error("File does not exists anymore, skipping: "+fileToDeleteRelative)
continue
if os.path.isdir(fileToDeleteFull) and os.listdir(fileToDeleteFull) and not os.path.islink(fileToDeleteFull):
# but is a non-empty directory, so skip it!
break
continue
if os.path.islink(fileToDeleteFull) or os.path.isfile(fileToDeleteFull):
# it's a regular file or symlink, so delete it. In case of symlink, removes only the link
# also removes the parent(s) directories if empty and expired
Expand All @@ -347,11 +347,11 @@ def applyChanges(filesDict):
# remove empty and expired directory
os.rmdir(os.path.join(DIRTOSCAN,aux))
aux=os.path.dirname(aux)
break
continue
if os.path.isdir(fileToDeleteFull) and not os.listdir(fileToDeleteFull):
# delete empty directory
os.rmdir(fileToDeleteFull)
break
continue

print(" -- unknown file type! skipping '"+fileToDelete+"'")
except Exception:
Expand Down

0 comments on commit e9e7d7b

Please sign in to comment.