filestore: Drop the .bin suffix
Closes https://github.com/tus/tusd/issues/210
This commit is contained in:
parent
141a49a38d
commit
647c65a125
|
@ -3,7 +3,7 @@
|
||||||
// FileStore is a storage backend used as a handler.DataStore in handler.NewHandler.
|
// FileStore is a storage backend used as a handler.DataStore in handler.NewHandler.
|
||||||
// It stores the uploads in a directory specified in two different files: The
|
// It stores the uploads in a directory specified in two different files: The
|
||||||
// `[id].info` files are used to store the fileinfo in JSON format. The
|
// `[id].info` files are used to store the fileinfo in JSON format. The
|
||||||
// `[id].bin` files contain the raw binary data uploaded.
|
// `[id]` files without an extension contain the raw binary data uploaded.
|
||||||
// No cleanup is performed so you may want to run a cronjob to ensure your disk
|
// No cleanup is performed so you may want to run a cronjob to ensure your disk
|
||||||
// is not filled up with old and finished uploads.
|
// is not filled up with old and finished uploads.
|
||||||
//
|
//
|
||||||
|
@ -67,7 +67,7 @@ func (store FileStore) NewUpload(info handler.FileInfo) (id string, err error) {
|
||||||
"Path": binPath,
|
"Path": binPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create .bin file with no content
|
// Create binary file with no content
|
||||||
file, err := os.OpenFile(binPath, os.O_CREATE|os.O_WRONLY, defaultFilePerm)
|
file, err := os.OpenFile(binPath, os.O_CREATE|os.O_WRONLY, defaultFilePerm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
|
@ -213,9 +213,9 @@ func (store FileStore) newLock(id string) (lockfile.Lockfile, error) {
|
||||||
return lockfile.Lockfile(path), nil
|
return lockfile.Lockfile(path), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// binPath returns the path to the .bin storing the binary data.
|
// binPath returns the path to the file storing the binary data.
|
||||||
func (store FileStore) binPath(id string) string {
|
func (store FileStore) binPath(id string) string {
|
||||||
return filepath.Join(store.Path, id+".bin")
|
return filepath.Join(store.Path, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// infoPath returns the path to the .info file storing the file's info.
|
// infoPath returns the path to the .info file storing the file's info.
|
||||||
|
|
|
@ -47,7 +47,7 @@ func TestFilestore(t *testing.T) {
|
||||||
a.Equal(handler.MetaData{"hello": "world"}, info.MetaData)
|
a.Equal(handler.MetaData{"hello": "world"}, info.MetaData)
|
||||||
a.Equal(2, len(info.Storage))
|
a.Equal(2, len(info.Storage))
|
||||||
a.Equal("filestore", info.Storage["Type"])
|
a.Equal("filestore", info.Storage["Type"])
|
||||||
a.Equal(filepath.Join(tmp, id+".bin"), info.Storage["Path"])
|
a.Equal(filepath.Join(tmp, id), info.Storage["Path"])
|
||||||
|
|
||||||
// Write data to upload
|
// Write data to upload
|
||||||
bytesWritten, err := store.WriteChunk(id, 0, strings.NewReader("hello world"))
|
bytesWritten, err := store.WriteChunk(id, 0, strings.NewReader("hello world"))
|
||||||
|
|
Loading…
Reference in New Issue