fileutils

package
v0.13.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 13 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPathFromBase64Hash

func GetPathFromBase64Hash(base64Hash types.Base64Hash, absBasePath config.Path) (string, error)

GetPathFromBase64Hash evaluates the path to a media file from its Base64Hash 3 subdirectories are created for more manageable browsing and use the remainder as the file name. For example, if Base64Hash is 'qwerty', the path will be 'q/w/erty/file'.

func MoveFileWithHashCheck

func MoveFileWithHashCheck(tmpDir types.Path, mediaMetadata *types.MediaMetadata, absBasePath config.Path, logger *log.Entry) (types.Path, bool, error)

MoveFileWithHashCheck checks for hash collisions when moving a temporary file to its final path based on metadata The final path is based on the hash of the file. If the final path exists and the file size matches, the file does not need to be moved. In error cases where the file is not a duplicate, the caller may decide to remove the final path. Returns the final path of the file, whether it is a duplicate and an error.

func RemoveDir

func RemoveDir(dir types.Path, logger *log.Entry)

RemoveDir removes a directory and logs a warning in case of errors

func WriteTempFile

func WriteTempFile(
	ctx context.Context, reqReader io.Reader, absBasePath config.Path,
) (hash types.Base64Hash, size types.FileSizeBytes, path types.Path, err error)

WriteTempFile writes to a new temporary file. The file is deleted if there was an error while writing.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL