Skip to content

Commit ae6b3f8

Browse files
author
Austin Pua
committed
Fixed Django 1.10 deprecation warnings described in jazzband#586
1 parent 41fced3 commit ae6b3f8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pipeline/collector.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from collections import OrderedDict
66

7+
import django
78
from django.contrib.staticfiles import finders
89
from django.contrib.staticfiles.storage import staticfiles_storage
910
from django.utils import six
@@ -19,6 +20,11 @@ def __init__(self, storage=None):
1920
storage = staticfiles_storage
2021
self.storage = storage
2122

23+
def _get_modified_time(self, storage, prefixed_path):
24+
if django.VERSION[:2] >= (1, 10):
25+
return storage.get_modified_time(prefixed_path)
26+
return storage.modified_time(prefixed_path)
27+
2228
def clear(self, path=""):
2329
dirs, files = self.storage.listdir(path)
2430
for f in files:
@@ -65,14 +71,14 @@ def delete_file(self, path, prefixed_path, source_storage):
6571
if self.storage.exists(prefixed_path):
6672
try:
6773
# When was the target file modified last time?
68-
target_last_modified = self.storage.modified_time(prefixed_path)
74+
target_last_modified = self._get_modified_time(self.storage, prefixed_path)
6975
except (OSError, NotImplementedError, AttributeError):
7076
# The storage doesn't support ``modified_time`` or failed
7177
pass
7278
else:
7379
try:
7480
# When was the source file modified last time?
75-
source_last_modified = source_storage.modified_time(path)
81+
source_last_modified = self._get_modified_time(source_storage, prefixed_path)
7682
except (OSError, NotImplementedError, AttributeError):
7783
pass
7884
else:

0 commit comments

Comments
 (0)