sftpfs: set the correct file mode
This commit is contained in:
parent
0caeb68680
commit
ea096db8e4
7 changed files with 34 additions and 22 deletions
|
@ -44,7 +44,7 @@
|
|||
</table>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="card mb-4 border-left-info">
|
||||
<div class="card mb-2 border-left-info">
|
||||
<div class="card-body">No user connected</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
|
|
@ -11,13 +11,13 @@
|
|||
</div>
|
||||
<div class="card-body">
|
||||
{{if .Error}}
|
||||
<div class="card mb-4 border-left-warning">
|
||||
<div class="card mb-2 border-left-warning">
|
||||
<div class="card-body text-form-error">{{.Error}}</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{if .Success}}
|
||||
<div class="card mb-4 border-left-success">
|
||||
<div class="card mb-2 border-left-success">
|
||||
<div class="card-body">{{.Success}}</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
|
|
@ -88,8 +88,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="card mb-4 {{ if .Status.DataProvider.IsActive}}border-left-success{{else}}border-left-warning{{end}}">
|
||||
<div class="card mb-2 {{ if .Status.DataProvider.IsActive}}border-left-success{{else}}border-left-warning{{end}}">
|
||||
<div class="card-body">
|
||||
<h6 class="card-title font-weight-bold">Data provider</h6>
|
||||
<p class="card-text">
|
||||
|
|
|
@ -15,7 +15,7 @@ type FileInfo struct {
|
|||
}
|
||||
|
||||
// NewFileInfo creates file info.
|
||||
func NewFileInfo(name string, isDirectory bool, sizeInBytes int64, modTime time.Time, fullName bool) FileInfo {
|
||||
func NewFileInfo(name string, isDirectory bool, sizeInBytes int64, modTime time.Time, fullName bool) *FileInfo {
|
||||
mode := os.FileMode(0644)
|
||||
if isDirectory {
|
||||
mode = os.FileMode(0755) | os.ModeDir
|
||||
|
@ -25,7 +25,7 @@ func NewFileInfo(name string, isDirectory bool, sizeInBytes int64, modTime time.
|
|||
name = path.Base(name)
|
||||
}
|
||||
|
||||
return FileInfo{
|
||||
return &FileInfo{
|
||||
name: name,
|
||||
sizeInBytes: sizeInBytes,
|
||||
modTime: modTime,
|
||||
|
@ -34,31 +34,36 @@ func NewFileInfo(name string, isDirectory bool, sizeInBytes int64, modTime time.
|
|||
}
|
||||
|
||||
// Name provides the base name of the file.
|
||||
func (fi FileInfo) Name() string {
|
||||
func (fi *FileInfo) Name() string {
|
||||
return fi.name
|
||||
}
|
||||
|
||||
// Size provides the length in bytes for a file.
|
||||
func (fi FileInfo) Size() int64 {
|
||||
func (fi *FileInfo) Size() int64 {
|
||||
return fi.sizeInBytes
|
||||
}
|
||||
|
||||
// Mode provides the file mode bits
|
||||
func (fi FileInfo) Mode() os.FileMode {
|
||||
func (fi *FileInfo) Mode() os.FileMode {
|
||||
return fi.mode
|
||||
}
|
||||
|
||||
// ModTime provides the last modification time.
|
||||
func (fi FileInfo) ModTime() time.Time {
|
||||
func (fi *FileInfo) ModTime() time.Time {
|
||||
return fi.modTime
|
||||
}
|
||||
|
||||
// IsDir provides the abbreviation for Mode().IsDir()
|
||||
func (fi FileInfo) IsDir() bool {
|
||||
func (fi *FileInfo) IsDir() bool {
|
||||
return fi.mode&os.ModeDir != 0
|
||||
}
|
||||
|
||||
// SetMode sets the file mode
|
||||
func (fi *FileInfo) SetMode(mode os.FileMode) {
|
||||
fi.mode = mode
|
||||
}
|
||||
|
||||
// Sys provides the underlying data source (can return nil)
|
||||
func (fi FileInfo) Sys() interface{} {
|
||||
func (fi *FileInfo) Sys() interface{} {
|
||||
return fi.getFileInfoSys()
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ func (fs *GCSFs) ConnectionID() string {
|
|||
|
||||
// Stat returns a FileInfo describing the named file
|
||||
func (fs *GCSFs) Stat(name string) (os.FileInfo, error) {
|
||||
var result FileInfo
|
||||
var result *FileInfo
|
||||
var err error
|
||||
if name == "" || name == "." {
|
||||
err := fs.checkIfBucketExists()
|
||||
|
@ -136,7 +136,7 @@ func (fs *GCSFs) Stat(name string) (os.FileInfo, error) {
|
|||
}
|
||||
|
||||
func (fs *GCSFs) getStatCompat(name string) (os.FileInfo, error) {
|
||||
var result FileInfo
|
||||
var result *FileInfo
|
||||
attrs, err := fs.headObject(name + "/")
|
||||
if err != nil {
|
||||
return result, err
|
||||
|
|
|
@ -108,7 +108,7 @@ func (fs *S3Fs) ConnectionID() string {
|
|||
|
||||
// Stat returns a FileInfo describing the named file
|
||||
func (fs *S3Fs) Stat(name string) (os.FileInfo, error) {
|
||||
var result FileInfo
|
||||
var result *FileInfo
|
||||
if name == "/" || name == "." {
|
||||
err := fs.checkIfBucketExists()
|
||||
if err != nil {
|
||||
|
@ -144,7 +144,7 @@ func (fs *S3Fs) Stat(name string) (os.FileInfo, error) {
|
|||
}
|
||||
|
||||
func (fs *S3Fs) getStatForDir(name string) (os.FileInfo, error) {
|
||||
var result FileInfo
|
||||
var result *FileInfo
|
||||
obj, err := fs.headObject(name + "/")
|
||||
if err != nil {
|
||||
return result, err
|
||||
|
|
|
@ -151,7 +151,9 @@ func (fs *SFTPFs) Stat(name string) (os.FileInfo, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return NewFileInfo(info.Name(), info.IsDir(), info.Size(), info.ModTime(), false), nil
|
||||
fi := NewFileInfo(info.Name(), info.IsDir(), info.Size(), info.ModTime(), false)
|
||||
fi.SetMode(info.Mode())
|
||||
return fi, nil
|
||||
}
|
||||
|
||||
// Lstat returns a FileInfo describing the named file
|
||||
|
@ -163,7 +165,9 @@ func (fs *SFTPFs) Lstat(name string) (os.FileInfo, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return NewFileInfo(info.Name(), info.IsDir(), info.Size(), info.ModTime(), false), nil
|
||||
fi := NewFileInfo(info.Name(), info.IsDir(), info.Size(), info.ModTime(), false)
|
||||
fi.SetMode(info.Mode())
|
||||
return fi, nil
|
||||
}
|
||||
|
||||
// Open opens the named file for reading
|
||||
|
@ -272,10 +276,14 @@ func (fs *SFTPFs) ReadDir(dirname string) ([]os.FileInfo, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for idx, entry := range entries {
|
||||
entries[idx] = NewFileInfo(entry.Name(), entry.IsDir(), entry.Size(), entry.ModTime(), false)
|
||||
result := make([]os.FileInfo, 0, len(entries))
|
||||
|
||||
for _, entry := range entries {
|
||||
info := NewFileInfo(entry.Name(), entry.IsDir(), entry.Size(), entry.ModTime(), false)
|
||||
info.SetMode(entry.Mode())
|
||||
result = append(result, info)
|
||||
}
|
||||
return entries, nil
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// IsUploadResumeSupported returns true if upload resume is supported.
|
||||
|
|
Loading…
Reference in a new issue