forked from forgejo/forgejo
* Add migrate repo archiver and packages storage support on command line (#20757) * Add migrate repo archiver and packages storage support on command line * Fix typo * Use stdCtx * Use packageblob and fix command description * Add migrate packages unit tests * Fix comment year * Fix the migrate storage command line description * Update cmd/migrate_storage.go Co-authored-by: zeripath <art27@cantab.net> * Update cmd/migrate_storage.go Co-authored-by: zeripath <art27@cantab.net> * Update cmd/migrate_storage.go Co-authored-by: zeripath <art27@cantab.net> * Fix test Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: zeripath <art27@cantab.net> * bug fix Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
parent
b43d7e1254
commit
7a9b01a2dd
11 changed files with 189 additions and 136 deletions
|
@ -226,28 +226,6 @@ func DeleteAttachmentsByRelease(releaseID int64) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// IterateAttachment iterates attachments; it should not be used when Gitea is servicing users.
|
||||
func IterateAttachment(f func(attach *Attachment) error) error {
|
||||
var start int
|
||||
const batchSize = 100
|
||||
for {
|
||||
attachments := make([]*Attachment, 0, batchSize)
|
||||
if err := db.GetEngine(db.DefaultContext).Limit(batchSize, start).Find(&attachments); err != nil {
|
||||
return err
|
||||
}
|
||||
if len(attachments) == 0 {
|
||||
return nil
|
||||
}
|
||||
start += len(attachments)
|
||||
|
||||
for _, attach := range attachments {
|
||||
if err := f(attach); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// CountOrphanedAttachments returns the number of bad attachments
|
||||
func CountOrphanedAttachments() (int64, error) {
|
||||
return db.GetEngine(db.DefaultContext).Where("(issue_id > 0 and issue_id not in (select id from issue)) or (release_id > 0 and release_id not in (select id from `release`))").
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue