style: gofumpt all the things (#9829)
Literally `gofumpt -w .` from the top level dir. Guaranteed to be minor style changes only and nothing else. @imsodin per request?
This commit is contained in:
@@ -101,7 +101,7 @@ func (w *AtomicWriter) Close() error {
|
||||
// On Windows, we might not be allowed to rename over the file
|
||||
// because it's read-only. Get us some write permissions and try
|
||||
// again.
|
||||
_ = w.fs.Chmod(w.path, 0644)
|
||||
_ = w.fs.Chmod(w.path, 0o644)
|
||||
err = w.fs.Rename(w.next.Name(), w.path)
|
||||
}
|
||||
if err != nil {
|
||||
|
||||
@@ -17,7 +17,7 @@ func TestCreateAtomicCreate(t *testing.T) {
|
||||
os.RemoveAll("testdata")
|
||||
defer os.RemoveAll("testdata")
|
||||
|
||||
if err := os.Mkdir("testdata", 0755); err != nil {
|
||||
if err := os.Mkdir("testdata", 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -52,10 +52,11 @@ func TestCreateAtomicCreate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateAtomicReplace(t *testing.T) {
|
||||
testCreateAtomicReplace(t, 0666)
|
||||
testCreateAtomicReplace(t, 0o666)
|
||||
}
|
||||
|
||||
func TestCreateAtomicReplaceReadOnly(t *testing.T) {
|
||||
testCreateAtomicReplace(t, 0444) // windows compatible read-only bits
|
||||
testCreateAtomicReplace(t, 0o444) // windows compatible read-only bits
|
||||
}
|
||||
|
||||
func testCreateAtomicReplace(t *testing.T, oldPerms os.FileMode) {
|
||||
@@ -66,7 +67,7 @@ func testCreateAtomicReplace(t *testing.T, oldPerms os.FileMode) {
|
||||
|
||||
os.RemoveAll(testdir)
|
||||
|
||||
if err := os.Mkdir(testdir, 0755); err != nil {
|
||||
if err := os.Mkdir(testdir, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ func TestTempFilePermissions(t *testing.T) {
|
||||
// The temp file should have 0600 permissions at the most, or we have a
|
||||
// security problem in CreateAtomic.
|
||||
t.Logf("Got 0%03o", info.Mode())
|
||||
if info.Mode()&^0600 != 0 {
|
||||
if info.Mode()&^0o600 != 0 {
|
||||
t.Errorf("Permission 0%03o is too generous", info.Mode())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,14 +84,14 @@ func Copy(method fs.CopyRangeMethod, src, dst fs.Filesystem, from, to string) (e
|
||||
func withPreparedTarget(filesystem fs.Filesystem, from, to string, f func() error) error {
|
||||
// Make sure the destination directory is writeable
|
||||
toDir := filepath.Dir(to)
|
||||
if info, err := filesystem.Stat(toDir); err == nil && info.IsDir() && info.Mode()&0200 == 0 {
|
||||
filesystem.Chmod(toDir, 0755)
|
||||
if info, err := filesystem.Stat(toDir); err == nil && info.IsDir() && info.Mode()&0o200 == 0 {
|
||||
filesystem.Chmod(toDir, 0o755)
|
||||
defer filesystem.Chmod(toDir, info.Mode())
|
||||
}
|
||||
|
||||
// On Windows, make sure the destination file is writeable (or we can't delete it)
|
||||
if build.IsWindows {
|
||||
filesystem.Chmod(to, 0666)
|
||||
filesystem.Chmod(to, 0o666)
|
||||
if !strings.EqualFold(from, to) {
|
||||
err := filesystem.Remove(to)
|
||||
if err != nil && !fs.IsNotExist(err) {
|
||||
|
||||
@@ -16,8 +16,10 @@ import (
|
||||
"github.com/syncthing/syncthing/lib/fs"
|
||||
)
|
||||
|
||||
var rand uint32
|
||||
var randmu sync.Mutex
|
||||
var (
|
||||
rand uint32
|
||||
randmu sync.Mutex
|
||||
)
|
||||
|
||||
func reseed() uint32 {
|
||||
return uint32(time.Now().UnixNano() + int64(os.Getpid()))
|
||||
@@ -48,7 +50,7 @@ func TempFile(filesystem fs.Filesystem, dir, prefix string) (f fs.File, err erro
|
||||
nconflict := 0
|
||||
for i := 0; i < 10000; i++ {
|
||||
name := filepath.Join(dir, prefix+nextSuffix())
|
||||
f, err = filesystem.OpenFile(name, fs.OptReadWrite|fs.OptCreate|fs.OptExclusive, 0600)
|
||||
f, err = filesystem.OpenFile(name, fs.OptReadWrite|fs.OptCreate|fs.OptExclusive, 0o600)
|
||||
if fs.IsExist(err) {
|
||||
if nconflict++; nconflict > 10 {
|
||||
randmu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user