1
0
Fork 0
mirror of synced 2024-05-29 16:40:06 +12:00

Set file creation times to the post creation time (#391)

This commit is contained in:
Serene 2021-05-17 20:49:35 +10:00 committed by GitHub
parent 71da1556e5
commit c581bef790
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,6 +10,7 @@ import os
import re
import shutil
import socket
import time
from datetime import datetime
from enum import Enum, auto
from multiprocessing import Pool
@ -440,6 +441,8 @@ class RedditDownloader:
with open(destination, 'wb') as file:
file.write(res.content)
logger.debug(f'Written file to {destination}')
creation_time = time.mktime(datetime.fromtimestamp(submission.created_utc).timetuple())
os.utime(destination, (creation_time, creation_time))
self.master_hash_list[resource_hash] = destination
logger.debug(f'Hash added to master list: {resource_hash}')
logger.info(f'Downloaded submission {submission.id} from {submission.subreddit.display_name}')