mirror of
https://github.com/restic/restic.git
synced 2025-12-14 02:57:04 +00:00
backup: allow excluding online-only cloud files
This commit is contained in:
committed by
Michael Eischer
parent
de3acd7937
commit
da71e77b28
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user