-
Notifications
You must be signed in to change notification settings - Fork 575
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
```yml # Exclude from backup: "all", "disks" or "none" # Specify which file in the instance's configuration to exclude from backup. # Only available on macOS. # 🟢 Builtin default: "disks" excludeFromBackup: null ``` Sets the `NSURLIsExcludedFromBackupKey` attribute to: - "all": the instance directory - "disks": `basedisk` and `diffdisk` files - "none": none Signed-off-by: Norio Nomura <norio.nomura@gmail.com> Update pkg/start/start.go Fix typo Co-authored-by: Jan Dubois <jan@jandubois.com> Update pkg/limayaml/validate.go Fix typo Co-authored-by: Jan Dubois <jan@jandubois.com>
- Loading branch information
1 parent
4e1cfac
commit db1e3fb
Showing
8 changed files
with
124 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package osutil | ||
|
||
/* | ||
#cgo darwin CFLAGS: -mmacosx-version-min=11 -x objective-c | ||
#cgo darwin LDFLAGS: -lobjc -framework Foundation | ||
#import <Foundation/Foundation.h> | ||
void setExcludeFromBackup(const char *path, int exclude) { | ||
@autoreleasepool { | ||
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithUTF8String:path]]; | ||
NSError *error = nil; | ||
if (![url setResourceValue: exclude == 1 ? @YES : @NO forKey:NSURLIsExcludedFromBackupKey error:&error]) { | ||
NSLog(@"setResourceValue failed: %@", error); | ||
} | ||
} | ||
} | ||
*/ | ||
import "C" //nolint:gocritic | ||
/* | ||
The reason for separating the import statement is that CGO only recognizes the standalone import of "C". | ||
However, the linter tool `gocritic` incorrectly identifies this separation as a duplicate import and raises | ||
a `dupImport` warning. To avoid this warning, the `gocritic` check has been disabled. | ||
Ref: https://github.com/go-critic/go-critic/issues/845 | ||
*/ | ||
import ( | ||
"unsafe" //nolint:gocritic | ||
) | ||
|
||
// SetExcludeFromBackup sets the `NSURLIsExcludedFromBackupKey` attribute of the specified file or directory. | ||
func SetExcludeFromBackup(path string, exclude bool) { | ||
cs := C.CString(path) | ||
defer C.free(unsafe.Pointer(cs)) | ||
if exclude { | ||
C.setExcludeFromBackup(cs, C.int(1)) | ||
} else { | ||
C.setExcludeFromBackup(cs, C.int(0)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
//go:build !darwin | ||
|
||
package osutil | ||
|
||
func SetExcludeFromBackup(path string, exclude bool) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters