repo_editor.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. // Copyright 2016 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package db
  5. import (
  6. "fmt"
  7. "io"
  8. "mime/multipart"
  9. "os"
  10. "os/exec"
  11. "path"
  12. "path/filepath"
  13. "strings"
  14. "time"
  15. "github.com/pkg/errors"
  16. gouuid "github.com/satori/go.uuid"
  17. "github.com/unknwon/com"
  18. "github.com/gogs/git-module"
  19. "gogs.io/gogs/internal/conf"
  20. "gogs.io/gogs/internal/cryptoutil"
  21. dberrors "gogs.io/gogs/internal/db/errors"
  22. "gogs.io/gogs/internal/gitutil"
  23. "gogs.io/gogs/internal/osutil"
  24. "gogs.io/gogs/internal/pathutil"
  25. "gogs.io/gogs/internal/process"
  26. "gogs.io/gogs/internal/tool"
  27. )
  28. const (
  29. ENV_AUTH_USER_ID = "GOGS_AUTH_USER_ID"
  30. ENV_AUTH_USER_NAME = "GOGS_AUTH_USER_NAME"
  31. ENV_AUTH_USER_EMAIL = "GOGS_AUTH_USER_EMAIL"
  32. ENV_REPO_OWNER_NAME = "GOGS_REPO_OWNER_NAME"
  33. ENV_REPO_OWNER_SALT_MD5 = "GOGS_REPO_OWNER_SALT_MD5"
  34. ENV_REPO_ID = "GOGS_REPO_ID"
  35. ENV_REPO_NAME = "GOGS_REPO_NAME"
  36. ENV_REPO_CUSTOM_HOOKS_PATH = "GOGS_REPO_CUSTOM_HOOKS_PATH"
  37. )
  38. type ComposeHookEnvsOptions struct {
  39. AuthUser *User
  40. OwnerName string
  41. OwnerSalt string
  42. RepoID int64
  43. RepoName string
  44. RepoPath string
  45. }
  46. func ComposeHookEnvs(opts ComposeHookEnvsOptions) []string {
  47. envs := []string{
  48. "SSH_ORIGINAL_COMMAND=1",
  49. ENV_AUTH_USER_ID + "=" + com.ToStr(opts.AuthUser.ID),
  50. ENV_AUTH_USER_NAME + "=" + opts.AuthUser.Name,
  51. ENV_AUTH_USER_EMAIL + "=" + opts.AuthUser.Email,
  52. ENV_REPO_OWNER_NAME + "=" + opts.OwnerName,
  53. ENV_REPO_OWNER_SALT_MD5 + "=" + cryptoutil.MD5(opts.OwnerSalt),
  54. ENV_REPO_ID + "=" + com.ToStr(opts.RepoID),
  55. ENV_REPO_NAME + "=" + opts.RepoName,
  56. ENV_REPO_CUSTOM_HOOKS_PATH + "=" + filepath.Join(opts.RepoPath, "custom_hooks"),
  57. }
  58. return envs
  59. }
  60. // ___________ .___.__ __ ___________.__.__
  61. // \_ _____/ __| _/|__|/ |_ \_ _____/|__| | ____
  62. // | __)_ / __ | | \ __\ | __) | | | _/ __ \
  63. // | \/ /_/ | | || | | \ | | |_\ ___/
  64. // /_______ /\____ | |__||__| \___ / |__|____/\___ >
  65. // \/ \/ \/ \/
  66. // discardLocalRepoBranchChanges discards local commits/changes of
  67. // given branch to make sure it is even to remote branch.
  68. func discardLocalRepoBranchChanges(localPath, branch string) error {
  69. if !com.IsExist(localPath) {
  70. return nil
  71. }
  72. // No need to check if nothing in the repository.
  73. if !git.RepoHasBranch(localPath, branch) {
  74. return nil
  75. }
  76. rev := "origin/" + branch
  77. if err := git.Reset(localPath, rev, git.ResetOptions{Hard: true}); err != nil {
  78. return fmt.Errorf("reset [revision: %s]: %v", rev, err)
  79. }
  80. return nil
  81. }
  82. func (repo *Repository) DiscardLocalRepoBranchChanges(branch string) error {
  83. return discardLocalRepoBranchChanges(repo.LocalCopyPath(), branch)
  84. }
  85. // CheckoutNewBranch checks out to a new branch from the a branch name.
  86. func (repo *Repository) CheckoutNewBranch(oldBranch, newBranch string) error {
  87. if err := git.Checkout(repo.LocalCopyPath(), newBranch, git.CheckoutOptions{
  88. BaseBranch: oldBranch,
  89. Timeout: time.Duration(conf.Git.Timeout.Pull) * time.Second,
  90. }); err != nil {
  91. return fmt.Errorf("checkout [base: %s, new: %s]: %v", oldBranch, newBranch, err)
  92. }
  93. return nil
  94. }
  95. type UpdateRepoFileOptions struct {
  96. OldBranch string
  97. NewBranch string
  98. OldTreeName string
  99. NewTreeName string
  100. Message string
  101. Content string
  102. IsNewFile bool
  103. }
  104. // UpdateRepoFile adds or updates a file in repository.
  105. func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) (err error) {
  106. // 🚨 SECURITY: Prevent uploading files into the ".git" directory
  107. if isRepositoryGitPath(opts.NewTreeName) {
  108. return errors.Errorf("bad tree path %q", opts.NewTreeName)
  109. }
  110. repoWorkingPool.CheckIn(com.ToStr(repo.ID))
  111. defer repoWorkingPool.CheckOut(com.ToStr(repo.ID))
  112. if err = repo.DiscardLocalRepoBranchChanges(opts.OldBranch); err != nil {
  113. return fmt.Errorf("discard local repo branch[%s] changes: %v", opts.OldBranch, err)
  114. } else if err = repo.UpdateLocalCopyBranch(opts.OldBranch); err != nil {
  115. return fmt.Errorf("update local copy branch[%s]: %v", opts.OldBranch, err)
  116. }
  117. repoPath := repo.RepoPath()
  118. localPath := repo.LocalCopyPath()
  119. if opts.OldBranch != opts.NewBranch {
  120. // Directly return error if new branch already exists in the server
  121. if git.RepoHasBranch(repoPath, opts.NewBranch) {
  122. return dberrors.BranchAlreadyExists{Name: opts.NewBranch}
  123. }
  124. // Otherwise, delete branch from local copy in case out of sync
  125. if git.RepoHasBranch(localPath, opts.NewBranch) {
  126. if err = git.DeleteBranch(localPath, opts.NewBranch, git.DeleteBranchOptions{
  127. Force: true,
  128. }); err != nil {
  129. return fmt.Errorf("delete branch %q: %v", opts.NewBranch, err)
  130. }
  131. }
  132. if err := repo.CheckoutNewBranch(opts.OldBranch, opts.NewBranch); err != nil {
  133. return fmt.Errorf("checkout new branch[%s] from old branch[%s]: %v", opts.NewBranch, opts.OldBranch, err)
  134. }
  135. }
  136. oldFilePath := path.Join(localPath, opts.OldTreeName)
  137. filePath := path.Join(localPath, opts.NewTreeName)
  138. if err = os.MkdirAll(path.Dir(filePath), os.ModePerm); err != nil {
  139. return err
  140. }
  141. // If it's meant to be a new file, make sure it doesn't exist.
  142. if opts.IsNewFile {
  143. if com.IsExist(filePath) {
  144. return ErrRepoFileAlreadyExist{filePath}
  145. }
  146. }
  147. // Ignore move step if it's a new file under a directory.
  148. // Otherwise, move the file when name changed.
  149. if osutil.IsFile(oldFilePath) && opts.OldTreeName != opts.NewTreeName {
  150. if err = git.Move(localPath, opts.OldTreeName, opts.NewTreeName); err != nil {
  151. return fmt.Errorf("git mv %q %q: %v", opts.OldTreeName, opts.NewTreeName, err)
  152. }
  153. }
  154. if err = os.WriteFile(filePath, []byte(opts.Content), 0600); err != nil {
  155. return fmt.Errorf("write file: %v", err)
  156. }
  157. if err = git.Add(localPath, git.AddOptions{All: true}); err != nil {
  158. return fmt.Errorf("git add --all: %v", err)
  159. }
  160. err = git.CreateCommit(
  161. localPath,
  162. &git.Signature{
  163. Name: doer.DisplayName(),
  164. Email: doer.Email,
  165. When: time.Now(),
  166. },
  167. opts.Message,
  168. )
  169. if err != nil {
  170. return fmt.Errorf("commit changes on %q: %v", localPath, err)
  171. }
  172. err = git.Push(localPath, "origin", opts.NewBranch,
  173. git.PushOptions{
  174. CommandOptions: git.CommandOptions{
  175. Envs: ComposeHookEnvs(ComposeHookEnvsOptions{
  176. AuthUser: doer,
  177. OwnerName: repo.MustOwner().Name,
  178. OwnerSalt: repo.MustOwner().Salt,
  179. RepoID: repo.ID,
  180. RepoName: repo.Name,
  181. RepoPath: repo.RepoPath(),
  182. }),
  183. },
  184. },
  185. )
  186. if err != nil {
  187. return fmt.Errorf("git push origin %s: %v", opts.NewBranch, err)
  188. }
  189. return nil
  190. }
  191. // GetDiffPreview produces and returns diff result of a file which is not yet committed.
  192. func (repo *Repository) GetDiffPreview(branch, treePath, content string) (diff *gitutil.Diff, err error) {
  193. repoWorkingPool.CheckIn(com.ToStr(repo.ID))
  194. defer repoWorkingPool.CheckOut(com.ToStr(repo.ID))
  195. if err = repo.DiscardLocalRepoBranchChanges(branch); err != nil {
  196. return nil, fmt.Errorf("discard local repo branch[%s] changes: %v", branch, err)
  197. } else if err = repo.UpdateLocalCopyBranch(branch); err != nil {
  198. return nil, fmt.Errorf("update local copy branch[%s]: %v", branch, err)
  199. }
  200. localPath := repo.LocalCopyPath()
  201. filePath := path.Join(localPath, treePath)
  202. if err = os.MkdirAll(filepath.Dir(filePath), os.ModePerm); err != nil {
  203. return nil, err
  204. }
  205. if err = os.WriteFile(filePath, []byte(content), 0600); err != nil {
  206. return nil, fmt.Errorf("write file: %v", err)
  207. }
  208. cmd := exec.Command("git", "diff", treePath)
  209. cmd.Dir = localPath
  210. cmd.Stderr = os.Stderr
  211. stdout, err := cmd.StdoutPipe()
  212. if err != nil {
  213. return nil, fmt.Errorf("get stdout pipe: %v", err)
  214. }
  215. if err = cmd.Start(); err != nil {
  216. return nil, fmt.Errorf("start: %v", err)
  217. }
  218. pid := process.Add(fmt.Sprintf("GetDiffPreview [repo_path: %s]", repo.RepoPath()), cmd)
  219. defer process.Remove(pid)
  220. diff, err = gitutil.ParseDiff(stdout, conf.Git.MaxDiffFiles, conf.Git.MaxDiffLines, conf.Git.MaxDiffLineChars)
  221. if err != nil {
  222. return nil, fmt.Errorf("parse diff: %v", err)
  223. }
  224. if err = cmd.Wait(); err != nil {
  225. return nil, fmt.Errorf("wait: %v", err)
  226. }
  227. return diff, nil
  228. }
  229. // ________ .__ __ ___________.__.__
  230. // \______ \ ____ | | _____/ |_ ____ \_ _____/|__| | ____
  231. // | | \_/ __ \| | _/ __ \ __\/ __ \ | __) | | | _/ __ \
  232. // | ` \ ___/| |_\ ___/| | \ ___/ | \ | | |_\ ___/
  233. // /_______ /\___ >____/\___ >__| \___ > \___ / |__|____/\___ >
  234. // \/ \/ \/ \/ \/ \/
  235. //
  236. type DeleteRepoFileOptions struct {
  237. LastCommitID string
  238. OldBranch string
  239. NewBranch string
  240. TreePath string
  241. Message string
  242. }
  243. func (repo *Repository) DeleteRepoFile(doer *User, opts DeleteRepoFileOptions) (err error) {
  244. repoWorkingPool.CheckIn(com.ToStr(repo.ID))
  245. defer repoWorkingPool.CheckOut(com.ToStr(repo.ID))
  246. if err = repo.DiscardLocalRepoBranchChanges(opts.OldBranch); err != nil {
  247. return fmt.Errorf("discard local repo branch[%s] changes: %v", opts.OldBranch, err)
  248. } else if err = repo.UpdateLocalCopyBranch(opts.OldBranch); err != nil {
  249. return fmt.Errorf("update local copy branch[%s]: %v", opts.OldBranch, err)
  250. }
  251. if opts.OldBranch != opts.NewBranch {
  252. if err := repo.CheckoutNewBranch(opts.OldBranch, opts.NewBranch); err != nil {
  253. return fmt.Errorf("checkout new branch[%s] from old branch[%s]: %v", opts.NewBranch, opts.OldBranch, err)
  254. }
  255. }
  256. localPath := repo.LocalCopyPath()
  257. if err = os.Remove(path.Join(localPath, opts.TreePath)); err != nil {
  258. return fmt.Errorf("remove file %q: %v", opts.TreePath, err)
  259. }
  260. if err = git.Add(localPath, git.AddOptions{All: true}); err != nil {
  261. return fmt.Errorf("git add --all: %v", err)
  262. }
  263. err = git.CreateCommit(
  264. localPath,
  265. &git.Signature{
  266. Name: doer.DisplayName(),
  267. Email: doer.Email,
  268. When: time.Now(),
  269. },
  270. opts.Message,
  271. )
  272. if err != nil {
  273. return fmt.Errorf("commit changes to %q: %v", localPath, err)
  274. }
  275. err = git.Push(localPath, "origin", opts.NewBranch,
  276. git.PushOptions{
  277. CommandOptions: git.CommandOptions{
  278. Envs: ComposeHookEnvs(ComposeHookEnvsOptions{
  279. AuthUser: doer,
  280. OwnerName: repo.MustOwner().Name,
  281. OwnerSalt: repo.MustOwner().Salt,
  282. RepoID: repo.ID,
  283. RepoName: repo.Name,
  284. RepoPath: repo.RepoPath(),
  285. }),
  286. },
  287. },
  288. )
  289. if err != nil {
  290. return fmt.Errorf("git push origin %s: %v", opts.NewBranch, err)
  291. }
  292. return nil
  293. }
  294. // ____ ___ .__ .___ ___________.___.__
  295. // | | \______ | | _________ __| _/ \_ _____/| | | ____ ______
  296. // | | /\____ \| | / _ \__ \ / __ | | __) | | | _/ __ \ / ___/
  297. // | | / | |_> > |_( <_> ) __ \_/ /_/ | | \ | | |_\ ___/ \___ \
  298. // |______/ | __/|____/\____(____ /\____ | \___ / |___|____/\___ >____ >
  299. // |__| \/ \/ \/ \/ \/
  300. //
  301. // Upload represent a uploaded file to a repo to be deleted when moved
  302. type Upload struct {
  303. ID int64
  304. UUID string `xorm:"uuid UNIQUE"`
  305. Name string
  306. }
  307. // UploadLocalPath returns where uploads is stored in local file system based on given UUID.
  308. func UploadLocalPath(uuid string) string {
  309. return path.Join(conf.Repository.Upload.TempPath, uuid[0:1], uuid[1:2], uuid)
  310. }
  311. // LocalPath returns where uploads are temporarily stored in local file system.
  312. func (upload *Upload) LocalPath() string {
  313. return UploadLocalPath(upload.UUID)
  314. }
  315. // NewUpload creates a new upload object.
  316. func NewUpload(name string, buf []byte, file multipart.File) (_ *Upload, err error) {
  317. if tool.IsMaliciousPath(name) {
  318. return nil, fmt.Errorf("malicious path detected: %s", name)
  319. }
  320. upload := &Upload{
  321. UUID: gouuid.NewV4().String(),
  322. Name: name,
  323. }
  324. localPath := upload.LocalPath()
  325. if err = os.MkdirAll(path.Dir(localPath), os.ModePerm); err != nil {
  326. return nil, fmt.Errorf("mkdir all: %v", err)
  327. }
  328. fw, err := os.Create(localPath)
  329. if err != nil {
  330. return nil, fmt.Errorf("create: %v", err)
  331. }
  332. defer func() { _ = fw.Close() }()
  333. if _, err = fw.Write(buf); err != nil {
  334. return nil, fmt.Errorf("write: %v", err)
  335. } else if _, err = io.Copy(fw, file); err != nil {
  336. return nil, fmt.Errorf("copy: %v", err)
  337. }
  338. if _, err := x.Insert(upload); err != nil {
  339. return nil, err
  340. }
  341. return upload, nil
  342. }
  343. func GetUploadByUUID(uuid string) (*Upload, error) {
  344. upload := &Upload{UUID: uuid}
  345. has, err := x.Get(upload)
  346. if err != nil {
  347. return nil, err
  348. } else if !has {
  349. return nil, ErrUploadNotExist{0, uuid}
  350. }
  351. return upload, nil
  352. }
  353. func GetUploadsByUUIDs(uuids []string) ([]*Upload, error) {
  354. if len(uuids) == 0 {
  355. return []*Upload{}, nil
  356. }
  357. // Silently drop invalid uuids.
  358. uploads := make([]*Upload, 0, len(uuids))
  359. return uploads, x.In("uuid", uuids).Find(&uploads)
  360. }
  361. func DeleteUploads(uploads ...*Upload) (err error) {
  362. if len(uploads) == 0 {
  363. return nil
  364. }
  365. sess := x.NewSession()
  366. defer sess.Close()
  367. if err = sess.Begin(); err != nil {
  368. return err
  369. }
  370. ids := make([]int64, len(uploads))
  371. for i := 0; i < len(uploads); i++ {
  372. ids[i] = uploads[i].ID
  373. }
  374. if _, err = sess.In("id", ids).Delete(new(Upload)); err != nil {
  375. return fmt.Errorf("delete uploads: %v", err)
  376. }
  377. for _, upload := range uploads {
  378. localPath := upload.LocalPath()
  379. if !osutil.IsFile(localPath) {
  380. continue
  381. }
  382. if err := os.Remove(localPath); err != nil {
  383. return fmt.Errorf("remove upload: %v", err)
  384. }
  385. }
  386. return sess.Commit()
  387. }
  388. func DeleteUpload(u *Upload) error {
  389. return DeleteUploads(u)
  390. }
  391. func DeleteUploadByUUID(uuid string) error {
  392. upload, err := GetUploadByUUID(uuid)
  393. if err != nil {
  394. if IsErrUploadNotExist(err) {
  395. return nil
  396. }
  397. return fmt.Errorf("get upload by UUID[%s]: %v", uuid, err)
  398. }
  399. if err := DeleteUpload(upload); err != nil {
  400. return fmt.Errorf("delete upload: %v", err)
  401. }
  402. return nil
  403. }
  404. type UploadRepoFileOptions struct {
  405. LastCommitID string
  406. OldBranch string
  407. NewBranch string
  408. TreePath string
  409. Message string
  410. Files []string // In UUID format
  411. }
  412. // isRepositoryGitPath returns true if given path is or resides inside ".git"
  413. // path of the repository.
  414. //
  415. // TODO(unknwon): Move to repoutil during refactoring for this file.
  416. func isRepositoryGitPath(path string) bool {
  417. path = strings.ToLower(path)
  418. return strings.HasSuffix(path, ".git") ||
  419. strings.Contains(path, ".git/") ||
  420. strings.Contains(path, `.git\`) ||
  421. // Windows treats ".git." the same as ".git"
  422. strings.HasSuffix(path, ".git.") ||
  423. strings.Contains(path, ".git./") ||
  424. strings.Contains(path, `.git.\`)
  425. }
  426. func (repo *Repository) UploadRepoFiles(doer *User, opts UploadRepoFileOptions) error {
  427. if len(opts.Files) == 0 {
  428. return nil
  429. }
  430. // 🚨 SECURITY: Prevent uploading files into the ".git" directory
  431. if isRepositoryGitPath(opts.TreePath) {
  432. return errors.Errorf("bad tree path %q", opts.TreePath)
  433. }
  434. uploads, err := GetUploadsByUUIDs(opts.Files)
  435. if err != nil {
  436. return fmt.Errorf("get uploads by UUIDs[%v]: %v", opts.Files, err)
  437. }
  438. repoWorkingPool.CheckIn(com.ToStr(repo.ID))
  439. defer repoWorkingPool.CheckOut(com.ToStr(repo.ID))
  440. if err = repo.DiscardLocalRepoBranchChanges(opts.OldBranch); err != nil {
  441. return fmt.Errorf("discard local repo branch[%s] changes: %v", opts.OldBranch, err)
  442. } else if err = repo.UpdateLocalCopyBranch(opts.OldBranch); err != nil {
  443. return fmt.Errorf("update local copy branch[%s]: %v", opts.OldBranch, err)
  444. }
  445. if opts.OldBranch != opts.NewBranch {
  446. if err = repo.CheckoutNewBranch(opts.OldBranch, opts.NewBranch); err != nil {
  447. return fmt.Errorf("checkout new branch[%s] from old branch[%s]: %v", opts.NewBranch, opts.OldBranch, err)
  448. }
  449. }
  450. localPath := repo.LocalCopyPath()
  451. dirPath := path.Join(localPath, opts.TreePath)
  452. if err = os.MkdirAll(dirPath, os.ModePerm); err != nil {
  453. return err
  454. }
  455. // Copy uploaded files into repository
  456. for _, upload := range uploads {
  457. tmpPath := upload.LocalPath()
  458. if !osutil.IsFile(tmpPath) {
  459. continue
  460. }
  461. upload.Name = pathutil.Clean(upload.Name)
  462. // 🚨 SECURITY: Prevent uploading files into the ".git" directory
  463. if isRepositoryGitPath(upload.Name) {
  464. continue
  465. }
  466. targetPath := path.Join(dirPath, upload.Name)
  467. if err = com.Copy(tmpPath, targetPath); err != nil {
  468. return fmt.Errorf("copy: %v", err)
  469. }
  470. }
  471. if err = git.Add(localPath, git.AddOptions{All: true}); err != nil {
  472. return fmt.Errorf("git add --all: %v", err)
  473. }
  474. err = git.CreateCommit(
  475. localPath,
  476. &git.Signature{
  477. Name: doer.DisplayName(),
  478. Email: doer.Email,
  479. When: time.Now(),
  480. },
  481. opts.Message,
  482. )
  483. if err != nil {
  484. return fmt.Errorf("commit changes on %q: %v", localPath, err)
  485. }
  486. err = git.Push(localPath, "origin", opts.NewBranch,
  487. git.PushOptions{
  488. CommandOptions: git.CommandOptions{
  489. Envs: ComposeHookEnvs(ComposeHookEnvsOptions{
  490. AuthUser: doer,
  491. OwnerName: repo.MustOwner().Name,
  492. OwnerSalt: repo.MustOwner().Salt,
  493. RepoID: repo.ID,
  494. RepoName: repo.Name,
  495. RepoPath: repo.RepoPath(),
  496. }),
  497. },
  498. },
  499. )
  500. if err != nil {
  501. return fmt.Errorf("git push origin %s: %v", opts.NewBranch, err)
  502. }
  503. return DeleteUploads(uploads...)
  504. }