Browse Source

repo: update size after fork, migrate and mirror sync (#4336)

pull/4343/head
Unknwon 8 years ago
parent
commit
7a99e56893
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 5
      models/mirror.go
  2. 22
      models/repo.go

5
models/mirror.go

@ -164,6 +164,11 @@ func (m *Mirror) runSync() bool {
} }
return false return false
} }
if err := m.Repo.UpdateSize(); err != nil {
log.Error(2, "UpdateSize [repo_id: %d]: %v", m.Repo.ID, err)
}
if m.Repo.HasWiki() { if m.Repo.HasWiki() {
if _, stderr, err := process.ExecDir( if _, stderr, err := process.ExecDir(
timeout, wikiPath, fmt.Sprintf("Mirror.runSync: %s", wikiPath), timeout, wikiPath, fmt.Sprintf("Mirror.runSync: %s", wikiPath),

22
models/repo.go

@ -710,6 +710,10 @@ func MigrateRepository(doer, owner *User, opts MigrateRepoOptions) (*Repository,
if headBranch != nil { if headBranch != nil {
repo.DefaultBranch = headBranch.Name repo.DefaultBranch = headBranch.Name
} }
if err = repo.UpdateSize(); err != nil {
log.Error(2, "UpdateSize [repo_id: %d]: %v", repo.ID, err)
}
} }
if opts.IsMirror { if opts.IsMirror {
@ -2233,6 +2237,8 @@ func ForkRepository(doer, owner *User, baseRepo *Repository, name, desc string)
} }
repoPath := repo.repoPath(sess) repoPath := repo.repoPath(sess)
RemoveAllWithNotice("Repository path erase before creation", repoPath)
_, stderr, err := process.ExecTimeout(10*time.Minute, _, stderr, err := process.ExecTimeout(10*time.Minute,
fmt.Sprintf("ForkRepository 'git clone': %s/%s", owner.Name, repo.Name), fmt.Sprintf("ForkRepository 'git clone': %s/%s", owner.Name, repo.Name),
"git", "clone", "--bare", baseRepo.RepoPath(), repoPath) "git", "clone", "--bare", baseRepo.RepoPath(), repoPath)
@ -2249,15 +2255,23 @@ func ForkRepository(doer, owner *User, baseRepo *Repository, name, desc string)
if err = createDelegateHooks(repoPath); err != nil { if err = createDelegateHooks(repoPath); err != nil {
return nil, fmt.Errorf("createDelegateHooks: %v", err) return nil, fmt.Errorf("createDelegateHooks: %v", err)
} else if err = prepareWebhooks(sess, baseRepo, HOOK_EVENT_FORK, &api.ForkPayload{ }
if err = sess.Commit(); err != nil {
return nil, fmt.Errorf("Commit: %v", err)
}
if err = repo.UpdateSize(); err != nil {
log.Error(2, "UpdateSize [repo_id: %d]: %v", repo.ID, err)
}
if err = PrepareWebhooks(baseRepo, HOOK_EVENT_FORK, &api.ForkPayload{
Forkee: repo.APIFormat(nil), Forkee: repo.APIFormat(nil),
Repo: baseRepo.APIFormat(nil), Repo: baseRepo.APIFormat(nil),
Sender: doer.APIFormat(), Sender: doer.APIFormat(),
}); err != nil { }); err != nil {
return nil, fmt.Errorf("prepareWebhooks: %v", err) log.Error(2, "PrepareWebhooks [repo_id: %d]: %v", baseRepo.ID, err)
} }
return repo, nil
return repo, sess.Commit()
} }
func (repo *Repository) GetForks() ([]*Repository, error) { func (repo *Repository) GetForks() ([]*Repository, error) {

Loading…
Cancel
Save