mirror of https://github.com/stashapp/stash.git
Fix zip gallery renaming (#3036)
This commit is contained in:
parent
33de28ce5d
commit
4db0e48f73
|
@ -131,7 +131,6 @@ type scanFile struct {
|
||||||
*BaseFile
|
*BaseFile
|
||||||
fs FS
|
fs FS
|
||||||
info fs.FileInfo
|
info fs.FileInfo
|
||||||
zipFile *scanFile
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *scanJob) withTxn(ctx context.Context, fn func(ctx context.Context) error) error {
|
func (s *scanJob) withTxn(ctx context.Context, fn func(ctx context.Context) error) error {
|
||||||
|
@ -230,9 +229,15 @@ func (s *scanJob) queueFileFunc(ctx context.Context, f FS, zipFile *scanFile) fs
|
||||||
},
|
},
|
||||||
fs: f,
|
fs: f,
|
||||||
info: info,
|
info: info,
|
||||||
// there is no guarantee that the zip file has been scanned
|
}
|
||||||
// so we can't just plug in the id.
|
|
||||||
zipFile: zipFile,
|
if zipFile != nil {
|
||||||
|
zipFileID, err := s.getZipFileID(ctx, zipFile)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
ff.ZipFileID = zipFileID
|
||||||
|
ff.ZipFile = zipFile
|
||||||
}
|
}
|
||||||
|
|
||||||
if info.IsDir() {
|
if info.IsDir() {
|
||||||
|
@ -348,7 +353,7 @@ func (s *scanJob) processQueue(ctx context.Context) error {
|
||||||
func (s *scanJob) incrementProgress(f scanFile) {
|
func (s *scanJob) incrementProgress(f scanFile) {
|
||||||
// don't increment for files inside zip files since these aren't
|
// don't increment for files inside zip files since these aren't
|
||||||
// counted during the initial walking
|
// counted during the initial walking
|
||||||
if s.ProgressReports != nil && f.zipFile == nil {
|
if s.ProgressReports != nil && f.ZipFile == nil {
|
||||||
s.ProgressReports.Increment()
|
s.ProgressReports.Increment()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -453,23 +458,12 @@ func (s *scanJob) onNewFolder(ctx context.Context, file scanFile) (*Folder, erro
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
toCreate := &Folder{
|
toCreate := &Folder{
|
||||||
DirEntry: DirEntry{
|
DirEntry: file.DirEntry,
|
||||||
ModTime: file.ModTime,
|
|
||||||
},
|
|
||||||
Path: file.Path,
|
Path: file.Path,
|
||||||
CreatedAt: now,
|
CreatedAt: now,
|
||||||
UpdatedAt: now,
|
UpdatedAt: now,
|
||||||
}
|
}
|
||||||
|
|
||||||
zipFileID, err := s.getZipFileID(ctx, file.zipFile)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if zipFileID != nil {
|
|
||||||
toCreate.ZipFileID = zipFileID
|
|
||||||
}
|
|
||||||
|
|
||||||
dir := filepath.Dir(file.Path)
|
dir := filepath.Dir(file.Path)
|
||||||
if dir != "." {
|
if dir != "." {
|
||||||
parentFolderID, err := s.getFolderID(ctx, dir)
|
parentFolderID, err := s.getFolderID(ctx, dir)
|
||||||
|
@ -601,15 +595,6 @@ func (s *scanJob) onNewFile(ctx context.Context, f scanFile) (File, error) {
|
||||||
|
|
||||||
baseFile.ParentFolderID = *parentFolderID
|
baseFile.ParentFolderID = *parentFolderID
|
||||||
|
|
||||||
zipFileID, err := s.getZipFileID(ctx, f.zipFile)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if zipFileID != nil {
|
|
||||||
baseFile.ZipFileID = zipFileID
|
|
||||||
}
|
|
||||||
|
|
||||||
const useExisting = false
|
const useExisting = false
|
||||||
fp, err := s.calculateFingerprints(f.fs, baseFile, path, useExisting)
|
fp, err := s.calculateFingerprints(f.fs, baseFile, path, useExisting)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -744,7 +729,8 @@ func (s *scanJob) handleRename(ctx context.Context, f File, fp []Fingerprint) (F
|
||||||
// TODO - handle #1426 scenario
|
// TODO - handle #1426 scenario
|
||||||
fs, err := s.getFileFS(other.Base())
|
fs, err := s.getFileFS(other.Base())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("getting FS for %q: %w", other.Base().Path, err)
|
missing = append(missing, other)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := fs.Lstat(other.Base().Path); err != nil {
|
if _, err := fs.Lstat(other.Base().Path); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue