use a new thread safe map
This commit is contained in:
@@ -43,8 +43,14 @@ func HandleHeadRequest(w http.ResponseWriter, r *http.Request, t *torrent.Torren
|
||||
accessKey := segments[len(segments)-2]
|
||||
filename := segments[len(segments)-1]
|
||||
|
||||
torrent, _ := t.TorrentMap.Get(accessKey)
|
||||
if torrent == nil {
|
||||
torrents, ok := t.DirectoryMap.Get(baseDirectory)
|
||||
if !ok {
|
||||
log.Warnf("Cannot find directory %s", baseDirectory)
|
||||
http.Error(w, "File not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
torrent, ok := torrents.Get(accessKey)
|
||||
if !ok {
|
||||
log.Warnf("Cannot find torrent %s in the directory %s", accessKey, baseDirectory)
|
||||
http.Error(w, "File not found", http.StatusNotFound)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user