Skip to content

Commit

Permalink
cmd: write warning when preserve ownership is not supported only once
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Dec 11, 2023
1 parent 38e441d commit 729b3d1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmd/minify/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,9 @@ func run() int {
preserveLinks = true
}
}
if preserveOwnership && !supportsGetOwnership {
Warning.Println(fmt.Errorf("preserve ownership not supported on platform"))
}

////////////////

Expand Down Expand Up @@ -960,8 +963,6 @@ Next:
if err != nil {
Warning.Println(err)
}
} else {
Warning.Println(fmt.Errorf("preserve ownership not supported on platform"))
}
}
if preserveTimestamps {
Expand Down
2 changes: 2 additions & 0 deletions cmd/minify/syscall.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ package main

import "os"

var supportsGetOwnership = false

func getOwnership(info os.FileInfo) (int, int, bool) {
return 0, 0, false
}
2 changes: 2 additions & 0 deletions cmd/minify/syscall_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"syscall"
)

var supportsGetOwnership = true

func getOwnership(info os.FileInfo) (int, int, bool) {
if stat_t, ok := info.Sys().(*syscall.Stat_t); ok {
return int(stat_t.Uid), int(stat_t.Gid), true
Expand Down

0 comments on commit 729b3d1

Please sign in to comment.