From dc5a9ef497147a274a922ec4a8a1dd1d42b23fe9 Mon Sep 17 00:00:00 2001 From: OMEGARAZER <869111+OMEGARAZER@users.noreply.github.com> Date: Fri, 14 Oct 2022 18:15:49 -0400 Subject: [PATCH 1/2] link_to depreciation coverage Futureproof for link_to depreciation. https://bugs.python.org/issue39950 --- bdfr/downloader.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bdfr/downloader.py b/bdfr/downloader.py index 3b5a7e1..4f508fa 100644 --- a/bdfr/downloader.py +++ b/bdfr/downloader.py @@ -114,7 +114,10 @@ class RedditDownloader(RedditConnector): f'Resource hash {resource_hash} from submission {submission.id} downloaded elsewhere') return elif self.args.make_hard_links: - self.master_hash_list[resource_hash].link_to(destination) + try: + destination.hardlink_to(self.master_hash_list[resource_hash]) + except: + self.master_hash_list[resource_hash].link_to(destination) logger.info( f'Hard link made linking {destination} to {self.master_hash_list[resource_hash]}' f' in submission {submission.id}') From 3c7f85725eecff1cfc00458646311ec01c31b50a Mon Sep 17 00:00:00 2001 From: OMEGARAZER <869111+OMEGARAZER@users.noreply.github.com> Date: Tue, 8 Nov 2022 12:06:20 -0500 Subject: [PATCH 2/2] Narrow except Narrow except to AttributeError --- bdfr/downloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bdfr/downloader.py b/bdfr/downloader.py index 4f508fa..7709add 100644 --- a/bdfr/downloader.py +++ b/bdfr/downloader.py @@ -116,7 +116,7 @@ class RedditDownloader(RedditConnector): elif self.args.make_hard_links: try: destination.hardlink_to(self.master_hash_list[resource_hash]) - except: + except AttributeError: self.master_hash_list[resource_hash].link_to(destination) logger.info( f'Hard link made linking {destination} to {self.master_hash_list[resource_hash]}'