소스 검색

Track download count only if there is a limit, and rewrite metadata file only when the counter should be increased

at-2021
JustAnotherArchivist 3 년 전
부모
커밋
a7fd2aeffb
1개의 변경된 파일2개의 추가작업 그리고 4개의 파일을 삭제
  1. +2
    -4
      server/handlers.go

+ 2
- 4
server/handlers.go 파일 보기

@@ -663,13 +663,11 @@ func (s *Server) CheckMetadata(token, filename string, increaseDownload bool) (M
return metadata, errors.New("MaxDownloads expired.")
} else if !metadata.MaxDate.IsZero() && time.Now().After(metadata.MaxDate) {
return metadata, errors.New("MaxDate expired.")
} else {
} else if metadata.MaxDownloads != -1 && increaseDownload {
// todo(nl5887): mutex?

// update number of downloads
if increaseDownload {
metadata.Downloads++
}
metadata.Downloads++

buffer := &bytes.Buffer{}
if err := json.NewEncoder(buffer).Encode(metadata); err != nil {


불러오는 중...
취소
저장