mirror of
https://github.com/nikdoof/tvorganise.git
synced 2025-12-13 06:42:16 +00:00
Check if file is on same partition, if so move it, if not copy it.
This commit is contained in:
@@ -158,6 +158,8 @@ def does_file_exist(path):
|
|||||||
file_exists = True
|
file_exists = True
|
||||||
return file_exists
|
return file_exists
|
||||||
|
|
||||||
|
def same_partition(f1, f2):
|
||||||
|
return os.stat(f1).st_dev == os.stat(f2).st_dev
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
|
|
||||||
@@ -190,14 +192,23 @@ def main():
|
|||||||
if file_exists:
|
if file_exists:
|
||||||
print "[!] File already exists, not copying"
|
print "[!] File already exists, not copying"
|
||||||
else:
|
else:
|
||||||
print "[*] Copying file"
|
if same_partition(oldfile, newpath):
|
||||||
try:
|
print "[* Moving file]"
|
||||||
shutil.copy(oldfile, newpath)
|
try:
|
||||||
except Exception, errormsg:
|
shutil.rename(oldfile, newpath)
|
||||||
print "[!] Error copying file! %s" % (errormsg)
|
except:
|
||||||
|
print "[!] Error moving file! %s" % (errormsg)
|
||||||
|
#end try
|
||||||
else:
|
else:
|
||||||
print "[*] ..done"
|
print "[*] Copying file"
|
||||||
#end try
|
try:
|
||||||
|
shutil.copy(oldfile, newpath)
|
||||||
|
except Exception, errormsg:
|
||||||
|
print "[!] Error copying file! %s" % (errormsg)
|
||||||
|
else:
|
||||||
|
print "[*] ..done"
|
||||||
|
#end try
|
||||||
|
#end if same_partition
|
||||||
#end if not file_exists
|
#end if not file_exists
|
||||||
else:
|
else:
|
||||||
print "Skipping file"
|
print "Skipping file"
|
||||||
|
|||||||
Reference in New Issue
Block a user