Beispiel #1
0
// getPreviousFile checks in the registrar if there is the newFile already exist with a different name
// In case an old file is found, the path to the file is returned
func (r *Registrar) getPreviousFile(newFilePath string, newFileInfo os.FileInfo) string {

	newState := input.GetOSFileState(&newFileInfo)

	for oldFilePath, oldState := range r.State {

		// Skipping when path the same
		if oldFilePath == newFilePath {
			continue
		}

		// Compare states
		if newState.IsSame(oldState.FileStateOS) {
			return oldFilePath

		}
	}

	return ""
}
Beispiel #2
0
// getPreviousFile checks in the registrar if there is the newFile already exist with a different name
// In case an old file is found, the path to the file is returned, if not, an error is returned
func (r *Registrar) getPreviousFile(newFilePath string, newFileInfo os.FileInfo) (string, error) {

	newState := input.GetOSFileState(&newFileInfo)

	for oldFilePath, oldState := range r.State {

		// Skipping when path the same
		if oldFilePath == newFilePath {
			continue
		}

		// Compare states
		if newState.IsSame(oldState.FileStateOS) {
			logp.Info("Old file with new name found: %s is no %s", oldFilePath, newFilePath)
			return oldFilePath, nil
		}
	}

	return "", fmt.Errorf("No previous file found")
}