diff --git a/elodie/filesystem.py b/elodie/filesystem.py index 55cab91..92b241c 100644 --- a/elodie/filesystem.py +++ b/elodie/filesystem.py @@ -381,22 +381,20 @@ class FileSystem(object): os.utime(dest_path, (stat.st_atime, stat.st_mtime)) else: 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.update_hash_db() 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. """ # Initialize date taken to what's returned from the metadata function. # 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 - file_path = media.get_file_path() - metadata = media.get_metadata() date_taken = metadata['date_taken'] base_name = metadata['base_name'] year_month_day_match = re.search( diff --git a/elodie/tests/filesystem_test.py b/elodie/tests/filesystem_test.py index 48ca096..6bf5aef 100644 --- a/elodie/tests/filesystem_test.py +++ b/elodie/tests/filesystem_test.py @@ -691,7 +691,7 @@ def test_set_utime_with_exif_date(): 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_checksum = helper.checksum(origin) @@ -720,7 +720,7 @@ def test_set_utime_without_exif_date(): 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_checksum = helper.checksum(origin)