MCPcopy
hub / github.com/pocketbase/pocketbase / processFilesToDelete

Method processFilesToDelete

core/field_file.go:476–496  ·  view source on GitHub ↗
(ctx context.Context, app App, record *Record)

Source from the content-addressed store, hash-verified

474}
475
476func (f *FileField) processFilesToDelete(ctx context.Context, app App, record *Record) error {
477 markedForDelete, _ := record.GetRaw(deletedFilesPrefix + f.Name).([]string)
478 if len(markedForDelete) == 0 {
479 return nil
480 }
481
482 old := list.ToInterfaceSlice(markedForDelete)
483 new := list.ToInterfaceSlice(f.extractPlainStrings(f.toSliceValue(record.GetRaw(f.Name))))
484 diff := f.excludeFiles(old, new)
485
486 toDelete := make([]string, len(diff))
487 for i, del := range diff {
488 toDelete[i] = f.getFileName(del)
489 }
490
491 failedToDelete, err := f.deleteFilesByNamesList(ctx, app, record, list.ToUniqueStringSlice(toDelete))
492
493 record.SetRaw(deletedFilesPrefix+f.Name, failedToDelete)
494
495 return err
496}
497
498func (f *FileField) rememberFilesToDelete(app App, record *Record, oldValue any) {
499 old := list.ToInterfaceSlice(f.extractPlainStrings(f.toSliceValue(oldValue)))

Callers 1

InterceptMethod · 0.95

Calls 9

extractPlainStringsMethod · 0.95
toSliceValueMethod · 0.95
excludeFilesMethod · 0.95
getFileNameMethod · 0.95
ToInterfaceSliceFunction · 0.92
ToUniqueStringSliceFunction · 0.92
GetRawMethod · 0.80
SetRawMethod · 0.80

Tested by

no test coverage detected