Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djrandom-py-deleted-112
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This project is pending deletion, and will be deleted on
2025-06-14
. Repository and other project resources are read-only.
Show more breadcrumbs
ale
djrandom-py-deleted-112
Commits
ef5efc89
Project 'ale/djrandom-py' was moved to 'ale/djrandom-py-deleted-112'. Please update any links and bookmarks that may still have the old path.
Commit
ef5efc89
authored
13 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
add robust error checking on the /dl/ endpoint
parent
7d4607b2
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/djrandom/frontend/views.py
+24
-0
24 additions, 0 deletions
server/djrandom/frontend/views.py
with
24 additions
and
0 deletions
server/djrandom/frontend/views.py
+
24
−
0
View file @
ef5efc89
...
...
@@ -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
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment