diff options
author | clsr <clsr@clsr.net> | 2016-06-28 20:00:06 +0200 |
---|---|---|
committer | clsr <clsr@clsr.net> | 2016-06-28 20:00:06 +0200 |
commit | 0e78c2307da4177fa49031e717c3688d21428695 (patch) | |
tree | 05f4a1247a8c95e14175bc0812e9f218ca5518d3 | |
parent | c4670ac63db5b4496bb5d2f6795d7b99af57a762 (diff) | |
download | gomf-0e78c2307da4177fa49031e717c3688d21428695.tar.gz gomf-0e78c2307da4177fa49031e717c3688d21428695.zip |
Remove storage folder path collisions for short IDsv0.3.0
-rw-r--r-- | USAGE | 2 | ||||
-rw-r--r-- | storage.go | 7 |
2 files changed, 5 insertions, 4 deletions
@@ -54,7 +54,7 @@ Running example: --name Example --id-charset CHARSET - sets the charset for file IDs in URLs to CHARSET; should only include URL-safe characters and no slashes or underscores + sets the charset for file IDs in URLs to CHARSET; should only include URL-safe characters and no slashes example: --id-charset 0123456789 --id-length LENGTH @@ -153,10 +153,11 @@ func (s *Storage) randomId() string { } func (s *Storage) idToFolder(subfolder, id string) string { - for len(id) < 3 { - id = "_" + id + name := id + for len(name) < 3 { + name = "_" + name } - return path.Join(s.Folder, subfolder, id[0:1], id[1:3], id) + return path.Join(s.Folder, subfolder, name[0:1], name[1:3], id) } func (s *Storage) readInput(w io.Writer, r io.Reader) (hash string, size int64, err error) { |