Documentation ¶
Index ¶
- func GenerateGamutMask(img image.Image, maskWidth, maskHeight, paddingX, paddingY int) (wheel *image.RGBA64)
- func GetFileMD5(fileName string) string
- func ProcessChangedFilesOnly(inputFolderName string, outputFolderName string, ...) error
- func ProcessChangedFilesOnlyRecursively(inputFolderName string, outputFolderName string, ...) error
- func SanitizeOutputFolder(outputFolderName string, ...) error
- type FileInfo
- type FileInfoList
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateGamutMask ¶
func GenerateGamutMask(img image.Image, maskWidth, maskHeight, paddingX, paddingY int) (wheel *image.RGBA64)
GenerateGamutMask generates a wheel (as *image.RGBA64) of Gamut Mask with a size of maskWidth, maskHeight
func GetFileMD5 ¶
GetFileMD5 will open the file, calculate and return its MD5 as a sequence of Hex symbols
func ProcessChangedFilesOnly ¶
func ProcessChangedFilesOnly( inputFolderName string, outputFolderName string, outputFileName func(inputFileName string) string, isInputFileForProcessing func(inputFolderName, inputFileName string) bool, fileInfoListJSONFullFileName string, processFileFunc func(fullInputFileName string, fullOutputFileName string) (int, error), beforeDeleteCallback func(folderName, fileName string) bool) error
ProcessChangedFilesOnly will check if the input folder has any changes by comparing files against the info saved in fileInfoListJSONFullFileName file, which will be generated and saved if does not exist.
For every new/updated file an processFileFunc will be called assuming it will produce an outputFile which name will be generated by calling outputFileName func. Necessity to call processFileFunc also arises naturally if outputFile is absent.
To help with filtering the files to process, isInputFileForProcessing should be provided.
To help sanitize output folder, beforeDeleteCallback may return false to ignore the file from deletion and return true to let the file in output folder be deleted. It will only be called for files that can be deleted according to fileInfoList.
When nil is passed for beforeDeleteCallback, no deletion for any file will happen.
func ProcessChangedFilesOnlyRecursively ¶
func ProcessChangedFilesOnlyRecursively( inputFolderName string, outputFolderName string, outputFileName func(inputFileName string) string, isInputFileForProcessing func(inputFolderName, inputFileName string) bool, fileInfoListJSONFullFileName func(inputFolderName string) string, processFileFunc func(fullInputFileName string, fullOutputFileName string) (int, error), beforeDeleteCallback func(folderName, fileName string) bool) error
ProcessChangedFilesOnlyRecursively walks through inputFolderName and all subfolders of it recursively and executes ProcessChangedFilesOnly against every found folder. The difference between ProcessChangedFilesOnly and ProcessChangedFilesOnlyRecursively is also that fileInfoListJSONFullFileName is a function that receives inputFolderName argument for every folder visited.
func SanitizeOutputFolder ¶
func SanitizeOutputFolder( outputFolderName string, beforeDeleteCallback func(folderName, fileName string) bool, fileInfoList *FileInfoList) error
SanitizeOutputFolder is automatically called after each ProcessChangedFilesOnly call but can also be called manually.
SanitizeOutputFolder removes all the files from outputFolderName that were not found in JSON's fileInfoList. We will also ignore files we are not supposed to touch by means of beforeDeleteCallback function which is expected to return true for files that can be deleted.
If beforeDeleteCallback function is not provided, we assume that no sanitizing should happen. But it only calls it in case the file is definitely not in the fileInfoList.
Returns a wrapped error in case output folder didn't exist or file's removal failed.
Types ¶
type FileInfo ¶
type FileInfo struct { InputName string OutputName string MD5 string `json:",omitempty"` Size int64 // Excessive data in case MD5 appears the same CreatedAt time.Time // Excessive data in case MD5 appears the same ProcessedAt time.Time // A hidden flag for processing removal data from JSON only FileFound bool `json:"-"` }
FileInfo type is to keep data about input folder files that have been processed
type FileInfoList ¶
type FileInfoList []FileInfo
FileInfoList is a list of FileInfo records that gets dumped into JSON file for minimizing the amount of necessary processing of new / updated files.