Combinate isfile and filesize query to one function

This commit is contained in:
shortcutme 2017-10-04 12:44:34 +02:00
parent edb9d3f719
commit 0dd34403a2
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
2 changed files with 25 additions and 10 deletions

View file

@ -123,6 +123,15 @@ def getDirname(path):
def getFilename(path):
return path[path.rfind("/") + 1:]
def getFilesize(path):
try:
s = os.stat(path)
except:
return None
if stat.S_ISREG(s.st_mode): # Test if it's file
return s.st_size
else:
return None
# Convert hash to hashid for hashfield
def toHashId(hash):