This commit is contained in:
parent
e5e811b215
commit
fbc7b04ef2
|
@ -381,22 +381,20 @@ class FileSystem(object):
|
||||||
os.utime(dest_path, (stat.st_atime, stat.st_mtime))
|
os.utime(dest_path, (stat.st_atime, stat.st_mtime))
|
||||||
else:
|
else:
|
||||||
compatability._copyfile(_file, dest_path)
|
compatability._copyfile(_file, dest_path)
|
||||||
self.set_utime(media)
|
self.set_utime_from_metadata(media.get_metadata(), dest_path)
|
||||||
|
|
||||||
db.add_hash(checksum, dest_path)
|
db.add_hash(checksum, dest_path)
|
||||||
db.update_hash_db()
|
db.update_hash_db()
|
||||||
|
|
||||||
return dest_path
|
return dest_path
|
||||||
|
|
||||||
def set_utime(self, media):
|
def set_utime_from_metadata(self, metadata, file_path):
|
||||||
""" Set the modification time on the file based on the file name.
|
""" Set the modification time on the file based on the file name.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Initialize date taken to what's returned from the metadata function.
|
# Initialize date taken to what's returned from the metadata function.
|
||||||
# If the folder and file name follow a time format of
|
# If the folder and file name follow a time format of
|
||||||
# YYYY-MM-DD_HH-MM-SS-IMG_0001.JPG then we override the date_taken
|
# YYYY-MM-DD_HH-MM-SS-IMG_0001.JPG then we override the date_taken
|
||||||
file_path = media.get_file_path()
|
|
||||||
metadata = media.get_metadata()
|
|
||||||
date_taken = metadata['date_taken']
|
date_taken = metadata['date_taken']
|
||||||
base_name = metadata['base_name']
|
base_name = metadata['base_name']
|
||||||
year_month_day_match = re.search(
|
year_month_day_match = re.search(
|
||||||
|
|
|
@ -691,7 +691,7 @@ def test_set_utime_with_exif_date():
|
||||||
|
|
||||||
assert initial_time != time.mktime(metadata_initial['date_taken'])
|
assert initial_time != time.mktime(metadata_initial['date_taken'])
|
||||||
|
|
||||||
filesystem.set_utime(media_initial)
|
filesystem.set_utime_from_metadata(media_initial.get_metadata(), media_initial.get_file_path())
|
||||||
final_stat = os.stat(origin)
|
final_stat = os.stat(origin)
|
||||||
final_checksum = helper.checksum(origin)
|
final_checksum = helper.checksum(origin)
|
||||||
|
|
||||||
|
@ -720,7 +720,7 @@ def test_set_utime_without_exif_date():
|
||||||
|
|
||||||
assert initial_time == time.mktime(metadata_initial['date_taken'])
|
assert initial_time == time.mktime(metadata_initial['date_taken'])
|
||||||
|
|
||||||
filesystem.set_utime(media_initial)
|
filesystem.set_utime_from_metadata(media_initial.get_metadata(), media_initial.get_file_path())
|
||||||
final_stat = os.stat(origin)
|
final_stat = os.stat(origin)
|
||||||
final_checksum = helper.checksum(origin)
|
final_checksum = helper.checksum(origin)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue