diff --git a/server/djrandom/frontend/views.py b/server/djrandom/frontend/views.py
index 8c187370db1cec97e7105cdf8753cda37f84a234..d70ae5ffc15e94c5c737d70b2da451504e736d5e 100644
--- a/server/djrandom/frontend/views.py
+++ b/server/djrandom/frontend/views.py
@@ -120,6 +120,30 @@ def download_song(sha1):
     mp3 = MP3.query.get(sha1)
     if not mp3:
         abort(404)
+
+    # This is a good time to check round-trip inconsistencies: if the
+    # user is requesting a duplicate file, it means our SOLR index got
+    # out of sync, but we can still give him the file he wants.
+    if mp3.state == MP3.DUPLICATE:
+        dup_mp3 = MP3.query.get(mp3.duplicate_of)
+        if not dup_mp3:
+            log.error(
+                'SEVERE: duplicate_of %s points to non-existing mp3 %s' % (
+                    mp3.sha1, mp3.duplicate_of))
+            abort(404)
+        log.error(
+            'inconsistency: user got duplicate song: %s (instead of %s)' % (
+                mp3.sha1, mp3.duplicate_of))
+        mp3 = dup_mp3
+    
+    if mp3.state != MP3.READY:
+        log.error('inconsistency: user got non-ready song: %s' % mp3.sha1)
+        abort(404)
+
+    if not os.path.exists(mp3.path):
+        log.error('SEVERE: file has disappeared for song: %s' % mp3.sha1)
+        abort(404)
+
     if use_xsendfile:
         return download_song_xsendfile(mp3)
     else: