|
|
@ -296,36 +296,6 @@ func fsCreateFile(filePath string, reader io.Reader, buf []byte, fallocSize int6 |
|
|
|
return bytesWritten, nil |
|
|
|
return bytesWritten, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Removes uploadID at destination path.
|
|
|
|
|
|
|
|
func fsRemoveUploadIDPath(basePath, uploadIDPath string) error { |
|
|
|
|
|
|
|
if basePath == "" || uploadIDPath == "" { |
|
|
|
|
|
|
|
return errors.Trace(errInvalidArgument) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if err := checkPathLength(basePath); err != nil { |
|
|
|
|
|
|
|
return errors.Trace(err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if err := checkPathLength(uploadIDPath); err != nil { |
|
|
|
|
|
|
|
return errors.Trace(err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// List all the entries in uploadID.
|
|
|
|
|
|
|
|
entries, err := readDir(uploadIDPath) |
|
|
|
|
|
|
|
if err != nil && err != errFileNotFound { |
|
|
|
|
|
|
|
return errors.Trace(err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Delete all the entries obtained from previous readdir.
|
|
|
|
|
|
|
|
for _, entryPath := range entries { |
|
|
|
|
|
|
|
err = fsDeleteFile(basePath, pathJoin(uploadIDPath, entryPath)) |
|
|
|
|
|
|
|
if err != nil && err != errFileNotFound { |
|
|
|
|
|
|
|
return errors.Trace(err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fsRemoveDir(uploadIDPath) |
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// fsFAllocate is similar to Fallocate but provides a convenient
|
|
|
|
// fsFAllocate is similar to Fallocate but provides a convenient
|
|
|
|
// wrapper to handle various operating system specific errors.
|
|
|
|
// wrapper to handle various operating system specific errors.
|
|
|
|
func fsFAllocate(fd int, offset int64, len int64) (err error) { |
|
|
|
func fsFAllocate(fd int, offset int64, len int64) (err error) { |
|
|
|