mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 14:50:56 +00:00
Use md5 hash of filename for temporary file (fixes #1786)
This commit is contained in:
parent
bcf51aed83
commit
285dcc30cf
@ -9,6 +9,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@ -25,7 +26,9 @@ func (t tempNamer) IsTemporary(name string) bool {
|
||||
}
|
||||
|
||||
func (t tempNamer) TempName(name string) string {
|
||||
hash := md5.New()
|
||||
hash.Write([]byte(name))
|
||||
tdir := filepath.Dir(name)
|
||||
tname := fmt.Sprintf("%s.%s", t.prefix, filepath.Base(name))
|
||||
tname := fmt.Sprintf("%s.%x", t.prefix, hash.Sum(nil))
|
||||
return filepath.Join(tdir, tname)
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@ -25,7 +26,9 @@ func (t tempNamer) IsTemporary(name string) bool {
|
||||
}
|
||||
|
||||
func (t tempNamer) TempName(name string) string {
|
||||
hash := md5.New()
|
||||
hash.Write([]byte(name))
|
||||
tdir := filepath.Dir(name)
|
||||
tname := fmt.Sprintf("%s.%s.tmp", t.prefix, filepath.Base(name))
|
||||
tname := fmt.Sprintf("%s.%x.tmp", t.prefix, hash.Sum(nil))
|
||||
return filepath.Join(tdir, tname)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user