Ver código fonte

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

at-2021
JustAnotherArchivist 3 anos atrás
pai
commit
a7fd2aeffb
1 arquivos alterados com 2 adições e 4 exclusões
  1. +2
    -4
      server/handlers.go

+ 2
- 4
server/handlers.go Ver arquivo

@@ -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 {


Carregando…
Cancelar
Salvar