os.path.samefile does not work on windows. My code checks if files handlers are the same instead

This commit is contained in:
Vakaris 2018-07-18 12:44:19 +03:00
parent 3118620c8a
commit dfecc6d6ac
1 changed files with 4 additions and 1 deletions

View File

@ -56,7 +56,10 @@ class MonkeyDrops(object):
return False
# we copy/move only in case path is different
file_moved = os.path.samefile(self._config['source_path'], self._config['destination_path'])
try:
file_moved = os.stat(self._config['source_path']) == os.stat(self._config['destination_path'])
except OSError:
file_moved = False
if not file_moved and os.path.exists(self._config['destination_path']):
os.remove(self._config['destination_path'])