mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-05-04 05:27:48 +08:00
fix 404 not found (#4536)
Signed-off-by: wang wusong <wangwusong@virtaitech.com> Co-authored-by: wang wusong <wangwusong@virtaitech.com>
This commit is contained in:
parent
5caff2c0f0
commit
d6af3a8eb6
@ -3,6 +3,7 @@ package filer
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/seaweedfs/seaweedfs/weed/glog"
|
"github.com/seaweedfs/seaweedfs/weed/glog"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
|
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
|
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
|
||||||
@ -28,12 +29,7 @@ func (f *Filer) DeleteEntryMetaAndData(ctx context.Context, p util.FullPath, isR
|
|||||||
isDeleteCollection := f.isBucket(entry)
|
isDeleteCollection := f.isBucket(entry)
|
||||||
if entry.IsDirectory() {
|
if entry.IsDirectory() {
|
||||||
// delete the folder children, not including the folder itself
|
// delete the folder children, not including the folder itself
|
||||||
err = f.doBatchDeleteFolderMetaAndData(ctx, entry, isRecursive, ignoreRecursiveError, shouldDeleteChunks && !isDeleteCollection, isDeleteCollection, isFromOtherCluster, signatures, func(chunks []*filer_pb.FileChunk) error {
|
err = f.doBatchDeleteFolderMetaAndData(ctx, entry, isRecursive, ignoreRecursiveError, shouldDeleteChunks && !isDeleteCollection, isDeleteCollection, isFromOtherCluster, signatures, func(hardLinkIds []HardLinkId) error {
|
||||||
if shouldDeleteChunks && !isDeleteCollection {
|
|
||||||
f.DirectDeleteChunks(chunks)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}, func(hardLinkIds []HardLinkId) error {
|
|
||||||
// A case not handled:
|
// A case not handled:
|
||||||
// what if the chunk is in a different collection?
|
// what if the chunk is in a different collection?
|
||||||
if shouldDeleteChunks {
|
if shouldDeleteChunks {
|
||||||
@ -47,16 +43,16 @@ func (f *Filer) DeleteEntryMetaAndData(ctx context.Context, p util.FullPath, isR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if shouldDeleteChunks && !isDeleteCollection {
|
|
||||||
f.DirectDeleteChunks(entry.GetChunks())
|
|
||||||
}
|
|
||||||
|
|
||||||
// delete the file or folder
|
// delete the file or folder
|
||||||
err = f.doDeleteEntryMetaAndData(ctx, entry, shouldDeleteChunks, isFromOtherCluster, signatures)
|
err = f.doDeleteEntryMetaAndData(ctx, entry, shouldDeleteChunks, isFromOtherCluster, signatures)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("delete file %s: %v", p, err)
|
return fmt.Errorf("delete file %s: %v", p, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if shouldDeleteChunks && !isDeleteCollection {
|
||||||
|
f.DirectDeleteChunks(entry.GetChunks())
|
||||||
|
}
|
||||||
|
|
||||||
if isDeleteCollection {
|
if isDeleteCollection {
|
||||||
collectionName := entry.Name()
|
collectionName := entry.Name()
|
||||||
f.doDeleteCollection(collectionName)
|
f.doDeleteCollection(collectionName)
|
||||||
@ -65,8 +61,10 @@ func (f *Filer) DeleteEntryMetaAndData(ctx context.Context, p util.FullPath, isR
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Filer) doBatchDeleteFolderMetaAndData(ctx context.Context, entry *Entry, isRecursive, ignoreRecursiveError, shouldDeleteChunks, isDeletingBucket, isFromOtherCluster bool, signatures []int32, onChunksFn OnChunksFunc, onHardLinkIdsFn OnHardLinkIdsFunc) (err error) {
|
func (f *Filer) doBatchDeleteFolderMetaAndData(ctx context.Context, entry *Entry, isRecursive, ignoreRecursiveError, shouldDeleteChunks, isDeletingBucket, isFromOtherCluster bool, signatures []int32, onHardLinkIdsFn OnHardLinkIdsFunc) (err error) {
|
||||||
|
|
||||||
|
//collect all the chunks of this layer and delete them together at the end
|
||||||
|
var chunksToDelete []*filer_pb.FileChunk
|
||||||
lastFileName := ""
|
lastFileName := ""
|
||||||
includeLastFile := false
|
includeLastFile := false
|
||||||
if !isDeletingBucket || !f.Store.CanDropWholeBucket() {
|
if !isDeletingBucket || !f.Store.CanDropWholeBucket() {
|
||||||
@ -86,14 +84,16 @@ func (f *Filer) doBatchDeleteFolderMetaAndData(ctx context.Context, entry *Entry
|
|||||||
lastFileName = sub.Name()
|
lastFileName = sub.Name()
|
||||||
if sub.IsDirectory() {
|
if sub.IsDirectory() {
|
||||||
subIsDeletingBucket := f.isBucket(sub)
|
subIsDeletingBucket := f.isBucket(sub)
|
||||||
err = f.doBatchDeleteFolderMetaAndData(ctx, sub, isRecursive, ignoreRecursiveError, shouldDeleteChunks, subIsDeletingBucket, false, nil, onChunksFn, onHardLinkIdsFn)
|
err = f.doBatchDeleteFolderMetaAndData(ctx, sub, isRecursive, ignoreRecursiveError, shouldDeleteChunks, subIsDeletingBucket, false, nil, onHardLinkIdsFn)
|
||||||
} else {
|
} else {
|
||||||
f.NotifyUpdateEvent(ctx, sub, nil, shouldDeleteChunks, isFromOtherCluster, nil)
|
f.NotifyUpdateEvent(ctx, sub, nil, shouldDeleteChunks, isFromOtherCluster, nil)
|
||||||
if len(sub.HardLinkId) != 0 {
|
if len(sub.HardLinkId) != 0 {
|
||||||
// hard link chunk data are deleted separately
|
// hard link chunk data are deleted separately
|
||||||
err = onHardLinkIdsFn([]HardLinkId{sub.HardLinkId})
|
err = onHardLinkIdsFn([]HardLinkId{sub.HardLinkId})
|
||||||
} else {
|
} else {
|
||||||
err = onChunksFn(sub.GetChunks())
|
if shouldDeleteChunks {
|
||||||
|
chunksToDelete = append(chunksToDelete, sub.GetChunks()...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil && !ignoreRecursiveError {
|
if err != nil && !ignoreRecursiveError {
|
||||||
@ -114,6 +114,7 @@ func (f *Filer) doBatchDeleteFolderMetaAndData(ctx context.Context, entry *Entry
|
|||||||
}
|
}
|
||||||
|
|
||||||
f.NotifyUpdateEvent(ctx, entry, nil, shouldDeleteChunks, isFromOtherCluster, signatures)
|
f.NotifyUpdateEvent(ctx, entry, nil, shouldDeleteChunks, isFromOtherCluster, signatures)
|
||||||
|
f.DeleteChunks(chunksToDelete)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user