Skip to content

Commit

Permalink
revert and purely use stat
Browse files Browse the repository at this point in the history
  • Loading branch information
Son Roy Almerol committed Nov 12, 2024
1 parent 7b68f5e commit e8a2842
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 48 deletions.
28 changes: 0 additions & 28 deletions internal/agent/sftp/eof.go

This file was deleted.

15 changes: 3 additions & 12 deletions internal/agent/sftp/filelister.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,9 @@ func (h *SftpHandler) FileStat(filename string) (*FileLister, error) {
var stat fs.FileInfo
var err error

isRoot := strings.TrimPrefix(filename, h.Snapshot.SnapshotPath) == ""

if isRoot {
stat, err = os.Stat(filename)
if err != nil {
return nil, err
}
} else {
stat, err = os.Lstat(filename)
if err != nil {
return nil, err
}
stat, err = os.Stat(filename)
if err != nil {
return nil, err
}

if skipFile(filename, stat) {
Expand Down
9 changes: 1 addition & 8 deletions internal/agent/sftp/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"fmt"
"io"
"log"
"os"
"sync"

"github.com/pkg/sftp"
Expand Down Expand Up @@ -46,13 +45,7 @@ func (h *SftpHandler) Fileread(r *sftp.Request) (io.ReaderAt, error) {
return nil, err
}

stat, err := os.Lstat(r.Filepath)
if err != nil {
log.Printf("error getting file stats: %v", err)
return nil, err
}

return NewEOFInjectingReaderAt(file, stat.Size()), nil
return file, nil
}

func (h *SftpHandler) Filewrite(r *sftp.Request) (io.WriterAt, error) {
Expand Down

0 comments on commit e8a2842

Please sign in to comment.