aboutsummaryrefslogtreecommitdiff
path: root/mediaapi/fileutils
diff options
context:
space:
mode:
Diffstat (limited to 'mediaapi/fileutils')
-rw-r--r--mediaapi/fileutils/fileutils.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/mediaapi/fileutils/fileutils.go b/mediaapi/fileutils/fileutils.go
index 36b2c5b8..1de242a0 100644
--- a/mediaapi/fileutils/fileutils.go
+++ b/mediaapi/fileutils/fileutils.go
@@ -49,7 +49,7 @@ func GetPathFromBase64Hash(base64Hash types.Base64Hash, absBasePath config.Path)
"file",
))
if err != nil {
- return "", fmt.Errorf("Unable to construct filePath: %q", err)
+ return "", fmt.Errorf("Unable to construct filePath: %w", err)
}
// check if the absolute absBasePath is a prefix of the absolute filePath
@@ -73,7 +73,7 @@ func MoveFileWithHashCheck(tmpDir types.Path, mediaMetadata *types.MediaMetadata
duplicate := false
finalPath, err := GetPathFromBase64Hash(mediaMetadata.Base64Hash, absBasePath)
if err != nil {
- return "", duplicate, fmt.Errorf("failed to get file path from metadata: %q", err)
+ return "", duplicate, fmt.Errorf("failed to get file path from metadata: %w", err)
}
var stat os.FileInfo
@@ -91,7 +91,7 @@ func MoveFileWithHashCheck(tmpDir types.Path, mediaMetadata *types.MediaMetadata
types.Path(finalPath),
)
if err != nil {
- return "", duplicate, fmt.Errorf("failed to move file to final destination (%v): %q", finalPath, err)
+ return "", duplicate, fmt.Errorf("failed to move file to final destination (%v): %w", finalPath, err)
}
return types.Path(finalPath), duplicate, nil
}
@@ -143,11 +143,11 @@ func moveFile(src types.Path, dst types.Path) error {
err := os.MkdirAll(dstDir, 0770)
if err != nil {
- return fmt.Errorf("Failed to make directory: %q", err)
+ return fmt.Errorf("Failed to make directory: %w", err)
}
err = os.Rename(string(src), string(dst))
if err != nil {
- return fmt.Errorf("Failed to move directory: %q", err)
+ return fmt.Errorf("Failed to move directory: %w", err)
}
return nil
}
@@ -155,11 +155,11 @@ func moveFile(src types.Path, dst types.Path) error {
func createTempFileWriter(absBasePath config.Path) (*bufio.Writer, *os.File, types.Path, error) {
tmpDir, err := createTempDir(absBasePath)
if err != nil {
- return nil, nil, "", fmt.Errorf("Failed to create temp dir: %q", err)
+ return nil, nil, "", fmt.Errorf("Failed to create temp dir: %w", err)
}
writer, tmpFile, err := createFileWriter(tmpDir)
if err != nil {
- return nil, nil, "", fmt.Errorf("Failed to create file writer: %q", err)
+ return nil, nil, "", fmt.Errorf("Failed to create file writer: %w", err)
}
return writer, tmpFile, tmpDir, nil
}
@@ -168,11 +168,11 @@ func createTempFileWriter(absBasePath config.Path) (*bufio.Writer, *os.File, typ
func createTempDir(baseDirectory config.Path) (types.Path, error) {
baseTmpDir := filepath.Join(string(baseDirectory), "tmp")
if err := os.MkdirAll(baseTmpDir, 0770); err != nil {
- return "", fmt.Errorf("Failed to create base temp dir: %v", err)
+ return "", fmt.Errorf("Failed to create base temp dir: %w", err)
}
tmpDir, err := ioutil.TempDir(baseTmpDir, "")
if err != nil {
- return "", fmt.Errorf("Failed to create temp dir: %v", err)
+ return "", fmt.Errorf("Failed to create temp dir: %w", err)
}
return types.Path(tmpDir), nil
}
@@ -184,7 +184,7 @@ func createFileWriter(directory types.Path) (*bufio.Writer, *os.File, error) {
filePath := filepath.Join(string(directory), "content")
file, err := os.Create(filePath)
if err != nil {
- return nil, nil, fmt.Errorf("Failed to create file: %v", err)
+ return nil, nil, fmt.Errorf("Failed to create file: %w", err)
}
return bufio.NewWriter(file), file, nil