mirror of
https://github.com/dutchcoders/transfer.sh.git
synced 2024-12-25 20:00:19 +01:00
Merge pull request #362 from JustAnotherArchivist/fix-metadata-rewrite
Only rewrite metadata file when the download counter changed
This commit is contained in:
commit
31ef712847
1 changed files with 2 additions and 4 deletions
|
@ -661,13 +661,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 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 {
|
||||
|
|
Loading…
Reference in a new issue