diff --git a/cmd/authorized_keys/main.go b/cmd/authorized_keys/main.go index c11a7bc..e7efbf2 100644 --- a/cmd/authorized_keys/main.go +++ b/cmd/authorized_keys/main.go @@ -17,7 +17,7 @@ func main() { logger := slog.Default() host := pobj.GetEnv("SSH_HOST", "0.0.0.0") port := pobj.GetEnv("SSH_PORT", "2222") - keyPath := pobj.GetEnv("SSH_AUTHORIZED_KEYS", "ssh_data/authorized_keys") + keyPath := pobj.GetEnv("SSH_AUTHORIZED_KEYS", "./ssh_data/authorized_keys") st, err := pobj.EnvDriverDetector(logger) if err != nil { diff --git a/storage/s3.go b/storage/s3.go index a81de52..4c34957 100644 --- a/storage/s3.go +++ b/storage/s3.go @@ -136,12 +136,24 @@ func (s *StorageS3) ListObjects(bucket Bucket, dir string, recursive bool) ([]os return fileList, err } + for _, pref := range page.CommonPrefixes { + modTime := time.Time{} + fname := strings.TrimSuffix(strings.TrimPrefix(*pref.Prefix, prefix), "/") + info := &utils.VirtualFile{ + FName: fname, + FIsDir: true, + FSize: 0, + FModTime: modTime, + } + fileList = append(fileList, info) + } + for _, obj := range page.Contents { - isDir := strings.HasSuffix(*obj.Key, string(os.PathSeparator)) modTime := obj.LastModified + fname := strings.TrimSuffix(strings.TrimPrefix(*obj.Key, prefix), "/") info := &utils.VirtualFile{ - FName: strings.TrimSuffix(strings.TrimPrefix(*obj.Key, prefix), "/"), - FIsDir: isDir, + FName: fname, + FIsDir: false, FSize: *obj.Size, FModTime: *modTime, } @@ -223,10 +235,11 @@ func (s *StorageS3) GetObject(bucket Bucket, fpath string) (utils.ReaderAtCloser } func (s *StorageS3) PutObject(bucket Bucket, fpath string, contents io.Reader, entry *utils.FileEntry) (string, int64, error) { + key := strings.TrimPrefix(fpath, "/") uploader := manager.NewUploader(s.Client) info, err := uploader.Upload(context.TODO(), &s3.PutObjectInput{ Bucket: aws.String(bucket.Name), - Key: aws.String(fpath), + Key: aws.String(key), Body: contents, }) if err != nil {