backup: allow excluding online-only cloud files

This commit is contained in:
Michael Wildman
2024-08-08 22:48:03 +12:00
committed by Michael Eischer
parent de3acd7937
commit da71e77b28
8 changed files with 154 additions and 1 deletions

View File

@@ -8,6 +8,8 @@ import (
"os"
"syscall"
"time"
"golang.org/x/sys/windows"
)
// extendedStat extracts info into an ExtendedFileInfo for Windows.
@@ -36,3 +38,20 @@ func extendedStat(fi os.FileInfo) *ExtendedFileInfo {
return &extFI
}
// RecallOnDataAccess checks if a file is available locally on the disk or if the file is
// just a placeholder which must be downloaded from a remote server. This is typically used
// in cloud syncing services (e.g. OneDrive) to prevent downloading files from cloud storage
// until they are accessed.
func (fi *ExtendedFileInfo) RecallOnDataAccess() (bool, error) {
attrs, ok := fi.sys.(*syscall.Win32FileAttributeData)
if !ok {
return false, fmt.Errorf("could not determine file attributes: %s", fi.Name)
}
if attrs.FileAttributes&windows.FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS > 0 {
return true, nil
}
return false, nil
}