diff --git a/api/funkwhale_api/audio/serializers.py b/api/funkwhale_api/audio/serializers.py
index cffa49b28..6b9227ded 100644
--- a/api/funkwhale_api/audio/serializers.py
+++ b/api/funkwhale_api/audio/serializers.py
@@ -384,12 +384,9 @@ def get_channel_from_rss_url(url, raise_exception=False):
library=channel.library,
delete_existing=True,
)
- latest_upload_date = max([upload.creation_date for upload in uploads])
- if (
- not channel.artist.modification_date
- or channel.artist.modification_date < latest_upload_date
- ):
- common_utils.update_modification_date(channel.artist)
+ if uploads:
+ latest_track_date = max([upload.track.creation_date for upload in uploads])
+ common_utils.update_modification_date(channel.artist, date=latest_track_date)
return channel, uploads
diff --git a/api/funkwhale_api/common/utils.py b/api/funkwhale_api/common/utils.py
index 98fd21355..6c4238fc4 100644
--- a/api/funkwhale_api/common/utils.py
+++ b/api/funkwhale_api/common/utils.py
@@ -410,15 +410,15 @@ def get_audio_mimetype(mt):
return aliases.get(mt, mt)
-def update_modification_date(obj, field="modification_date"):
+def update_modification_date(obj, field="modification_date", date=None):
IGNORE_DELAY = 60
current_value = getattr(obj, field)
- now = timezone.now()
- ignore = current_value is not None and current_value < now - datetime.timedelta(
+ date = date or timezone.now()
+ ignore = current_value is not None and current_value < date - datetime.timedelta(
seconds=IGNORE_DELAY
)
if ignore:
- setattr(obj, field, now)
- obj.__class__.objects.filter(pk=obj.pk).update(**{field: now})
+ setattr(obj, field, date)
+ obj.__class__.objects.filter(pk=obj.pk).update(**{field: date})
- return now
+ return date
diff --git a/api/tests/audio/test_serializers.py b/api/tests/audio/test_serializers.py
index f1dcd21c6..5ddef7c29 100644
--- a/api/tests/audio/test_serializers.py
+++ b/api/tests/audio/test_serializers.py
@@ -791,7 +791,7 @@ def test_get_channel_from_rss_url(db, r_mock, mocker):