mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-22 11:41:38 +00:00
mediaapi/writers/upload: Simplify storeFileAndMetadata description
This commit is contained in:
parent
9ecf620ad9
commit
9678cb6ea1
@ -213,13 +213,11 @@ func (r *uploadRequest) Validate(maxFileSizeBytes types.FileSizeBytes) *util.JSO
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// storeFileAndMetadata first moves a temporary file named content from tmpDir to its
|
// storeFileAndMetadata moves the temporary file to its final path based on metadata and stores the metadata in the database
|
||||||
// final path (see getPathFromMediaMetadata for details.) Once the file is moved, the
|
// See getPathFromMediaMetadata in fileutils for details of the final path.
|
||||||
// metadata about the file is written into the media repository database. This order
|
// The order of operations is important as it avoids metadata entering the database before the file
|
||||||
// of operations is important as it avoids metadata entering the database before the file
|
// is ready, and if we fail to move the file, it never gets added to the database.
|
||||||
// is ready and if we fail to move the file, it never gets added to the database.
|
// Returns a util.JSONResponse error and cleans up directories in case of error.
|
||||||
// In case of any error, appropriate files and directories are cleaned up a
|
|
||||||
// util.JSONResponse error is returned.
|
|
||||||
func (r *uploadRequest) storeFileAndMetadata(tmpDir types.Path, absBasePath types.Path, db *storage.Database) *util.JSONResponse {
|
func (r *uploadRequest) storeFileAndMetadata(tmpDir types.Path, absBasePath types.Path, db *storage.Database) *util.JSONResponse {
|
||||||
finalPath, duplicate, err := fileutils.MoveFileWithHashCheck(tmpDir, r.MediaMetadata, absBasePath, r.Logger)
|
finalPath, duplicate, err := fileutils.MoveFileWithHashCheck(tmpDir, r.MediaMetadata, absBasePath, r.Logger)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user