mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 15:30:06 +08:00
vfs: add --dir-perms and --file-perms flags - fixes #2897
This allows files to be shown with the execute bit which allows binaries to be run under Windows and Linux.
This commit is contained in:
parent
2d2533a08a
commit
554ee0d963
|
@ -43,7 +43,7 @@ var DefaultOpt = Options{
|
|||
Umask: 0,
|
||||
UID: ^uint32(0), // these values instruct WinFSP-FUSE to use the current user
|
||||
GID: ^uint32(0), // overriden for non windows in mount_unix.go
|
||||
DirPerms: os.FileMode(0777) | os.ModeDir,
|
||||
DirPerms: os.FileMode(0777),
|
||||
FilePerms: os.FileMode(0666),
|
||||
CacheMode: CacheModeOff,
|
||||
CacheMaxAge: 3600 * time.Second,
|
||||
|
|
34
vfs/vfsflags/filemode.go
Normal file
34
vfs/vfsflags/filemode.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package vfsflags
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// FileMode is a command line friendly os.FileMode
|
||||
type FileMode struct {
|
||||
Mode *os.FileMode
|
||||
}
|
||||
|
||||
// String turns FileMode into a string
|
||||
func (x *FileMode) String() string {
|
||||
return fmt.Sprintf("0%3o", *x.Mode)
|
||||
}
|
||||
|
||||
// Set a FileMode
|
||||
func (x *FileMode) Set(s string) error {
|
||||
i, err := strconv.ParseInt(s, 8, 64)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Bad FileMode - must be octal digits")
|
||||
}
|
||||
*x.Mode = (os.FileMode)(i)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Type of the value
|
||||
func (x *FileMode) Type() string {
|
||||
return "int"
|
||||
}
|
|
@ -11,6 +11,8 @@ import (
|
|||
// Options set by command line flags
|
||||
var (
|
||||
Opt = vfs.DefaultOpt
|
||||
DirPerms = &FileMode{Mode: &Opt.DirPerms}
|
||||
FilePerms = &FileMode{Mode: &Opt.FilePerms}
|
||||
)
|
||||
|
||||
// AddFlags adds the non filing system specific flags to the command
|
||||
|
@ -27,5 +29,7 @@ func AddFlags(flagSet *pflag.FlagSet) {
|
|||
flags.DurationVarP(flagSet, &Opt.CacheMaxAge, "vfs-cache-max-age", "", Opt.CacheMaxAge, "Max age of objects in the cache.")
|
||||
flags.FVarP(flagSet, &Opt.ChunkSize, "vfs-read-chunk-size", "", "Read the source objects in chunks.")
|
||||
flags.FVarP(flagSet, &Opt.ChunkSizeLimit, "vfs-read-chunk-size-limit", "", "If greater than --vfs-read-chunk-size, double the chunk size after each chunk read, until the limit is reached. 'off' is unlimited.")
|
||||
flags.FVarP(flagSet, DirPerms, "dir-perms", "", "Directory permissions")
|
||||
flags.FVarP(flagSet, FilePerms, "file-perms", "", "File permissions")
|
||||
platformFlags(flagSet)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user