mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-09 09:35:00 +09:00
GO-1340: Fix offload
This commit is contained in:
parent
53380d4151
commit
4627fbae86
3 changed files with 14 additions and 9 deletions
|
@ -68,9 +68,11 @@ func (s *service) FileListOffload(fileIDs []string, includeNotPinned bool) (tota
|
|||
if err != nil {
|
||||
return 0, 0, fmt.Errorf("list all files: %w", err)
|
||||
}
|
||||
fileIDs = lo.Map(allFiles, func(file *storage.FileInfo, _ int) string {
|
||||
return file.Hash
|
||||
|
||||
allTargets := lo.Map(allFiles, func(file *storage.FileInfo, _ int) []string {
|
||||
return file.Targets
|
||||
})
|
||||
fileIDs = lo.Uniq(lo.Flatten(allTargets))
|
||||
}
|
||||
|
||||
if !includeNotPinned {
|
||||
|
|
|
@ -60,6 +60,15 @@ func (i *indexer) ftIndexDoc(id string, _ time.Time) (err error) {
|
|||
if err != nil {
|
||||
sbType = smartblock.SmartBlockTypePage
|
||||
}
|
||||
|
||||
// Placed it here because I don't want to introduce a new queue now
|
||||
if sbType == smartblock.SmartBlockTypeFile {
|
||||
// file's hash is id
|
||||
err = i.reindexDoc(ctx, id)
|
||||
if err != nil {
|
||||
log.With("id", id).Errorf("failed to reindex file: %s", err.Error())
|
||||
}
|
||||
}
|
||||
indexDetails, _ := sbType.Indexable()
|
||||
if !indexDetails {
|
||||
return nil
|
||||
|
|
|
@ -224,7 +224,7 @@ func (i *indexer) Index(ctx context.Context, info smartblock2.DocInfo) error {
|
|||
log.With("thread", info.Id).Debugf("to index queue")
|
||||
}
|
||||
|
||||
go i.indexLinkedFiles(ctx, info.FileHashes)
|
||||
i.indexLinkedFiles(ctx, info.FileHashes)
|
||||
} else {
|
||||
_ = i.store.DeleteDetails(info.Id)
|
||||
}
|
||||
|
@ -260,12 +260,6 @@ func (i *indexer) indexLinkedFiles(ctx context.Context, fileHashes []string) {
|
|||
}
|
||||
newIDs := slice.Difference(fileHashes, existingIDs)
|
||||
for _, id := range newIDs {
|
||||
// file's hash is id
|
||||
err = i.reindexDoc(ctx, id)
|
||||
if err != nil {
|
||||
log.With("id", id).Errorf("failed to reindex file: %s", err.Error())
|
||||
}
|
||||
|
||||
err = i.store.AddToIndexQueue(id)
|
||||
if err != nil {
|
||||
log.With("id", id).Error(err.Error())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue