diff options
| author | Chris Lu <chris.lu@gmail.com> | 2019-12-13 00:23:05 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2019-12-13 00:23:05 -0800 |
| commit | bbb6ebc3c024e8f2992ba8ad4eb3426364e70566 (patch) | |
| tree | 8ef528f73c31d44103a652ccb850c34677dd9aa8 /weed/filer2/abstract_sql | |
| parent | 0fa1269bc77abe30f4d108a88a97e29e1bca3124 (diff) | |
| download | seaweedfs-bbb6ebc3c024e8f2992ba8ad4eb3426364e70566.tar.xz seaweedfs-bbb6ebc3c024e8f2992ba8ad4eb3426364e70566.zip | |
filer: DeleteFolderChildren for deleting large folders
Diffstat (limited to 'weed/filer2/abstract_sql')
| -rw-r--r-- | weed/filer2/abstract_sql/abstract_sql_store.go | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/weed/filer2/abstract_sql/abstract_sql_store.go b/weed/filer2/abstract_sql/abstract_sql_store.go index 3e8554957..d512467c7 100644 --- a/weed/filer2/abstract_sql/abstract_sql_store.go +++ b/weed/filer2/abstract_sql/abstract_sql_store.go @@ -10,13 +10,14 @@ import ( ) type AbstractSqlStore struct { - DB *sql.DB - SqlInsert string - SqlUpdate string - SqlFind string - SqlDelete string - SqlListExclusive string - SqlListInclusive string + DB *sql.DB + SqlInsert string + SqlUpdate string + SqlFind string + SqlDelete string + SqlDeleteFolderChildren string + SqlListExclusive string + SqlListInclusive string } type TxOrDB interface { @@ -132,6 +133,21 @@ func (store *AbstractSqlStore) DeleteEntry(ctx context.Context, fullpath filer2. return nil } +func (store *AbstractSqlStore) DeleteFolderChildren(ctx context.Context, fullpath filer2.FullPath) error { + + res, err := store.getTxOrDB(ctx).ExecContext(ctx, store.SqlDeleteFolderChildren, hashToLong(string(fullpath)), fullpath) + if err != nil { + return fmt.Errorf("deleteFolderChildren %s: %s", fullpath, err) + } + + _, err = res.RowsAffected() + if err != nil { + return fmt.Errorf("deleteFolderChildren %s but no rows affected: %s", fullpath, err) + } + + return nil +} + func (store *AbstractSqlStore) ListDirectoryEntries(ctx context.Context, fullpath filer2.FullPath, startFileName string, inclusive bool, limit int) (entries []*filer2.Entry, err error) { sqlText := store.SqlListExclusive |
