Skip to content

Commit 30656de

Browse files
committed
pr requests
1 parent 46d8c24 commit 30656de

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

cmd/restoreXcodeDerivedDataFiles.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var restoreXcodeDerivedDataFilesCmd = &cobra.Command{
4646
logger.Infof("(i) Checking parameters")
4747
projectRoot, _ := cmd.Flags().GetString("project-root")
4848
cacheKey, _ := cmd.Flags().GetString("key")
49-
forceOverwrite, _ := cmd.Flags().GetBool("force-overwrite")
49+
forceOverwrite, _ := cmd.Flags().GetBool("force-overwrite-files")
5050
maxLoggedErrors, _ := cmd.Flags().GetInt("max-logged-errors")
5151

5252
tracker := xcode.NewDefaultStepTracker("restore-xcode-build-cache", os.Getenv, logger)
@@ -91,7 +91,7 @@ func init() {
9191
if err := restoreXcodeDerivedDataFilesCmd.MarkFlagRequired("project-root"); err != nil {
9292
panic(err)
9393
}
94-
restoreXcodeDerivedDataFilesCmd.Flags().Bool("force-overwrite", false, "If set, the command will try to overwrite existing files during restoring the cache even if the permissions do not allow it")
94+
restoreXcodeDerivedDataFilesCmd.Flags().Bool("force-overwrite-files", false, "If set, the command will try to overwrite existing files during restoring the cache even if the permissions do not allow it")
9595
restoreXcodeDerivedDataFilesCmd.Flags().Int("max-logged-errors", 100, "The maximum number of errors logged to the console during restoring the cache.")
9696
}
9797

internal/xcode/download.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@ func downloadFile(ctx context.Context, client *kv.Client, filePath, key string,
4848
if fileInfo, err := os.Stat(filePath); err == nil {
4949
ownerWritable := (fileInfo.Mode().Perm() & 0200) != 0
5050
if !ownerWritable {
51-
if forceOverwrite {
52-
if err := os.Chmod(filePath, 0666); err != nil {
53-
return fmt.Errorf("force overwrite - failed to change existing file permissions: %w", err)
54-
}
55-
56-
if err := os.Remove(filePath); err != nil {
57-
return fmt.Errorf("force overwrite - failed to remove existing file: %w", err)
58-
}
59-
} else {
51+
if !forceOverwrite {
6052
return ErrFileExistsAndNotWritable
6153
}
54+
55+
if err := os.Chmod(filePath, 0666); err != nil {
56+
return fmt.Errorf("force overwrite - failed to change existing file permissions: %w", err)
57+
}
58+
59+
if err := os.Remove(filePath); err != nil {
60+
return fmt.Errorf("force overwrite - failed to remove existing file: %w", err)
61+
}
6262
}
6363
}
6464

0 commit comments

Comments
 (0)