Skip to content

Adding repository which exists in repo ROOT but not in DB removes its files #8085

Closed

Description

@gerab

Gogs version

0.13.3

Git version

  • Server: 2.47.3
  • Client: 2.52.0.windows.1

Operating system

Debian 13

Database

SQLite 3

Describe the bug

I'm recovering my instance after a server failure with a slightly outdated DB file. Some repositories that physically exist on the disk are not shown in Gogs, which is expected. I've just tried to add (recover) a "new" repository, which already exists by adding a new repo with the same name that it had before the failure.

Achieved result:

  • Gogs alerts about the path already exists and wipes the repository files completely, and they cannot be recovered anymore

To reproduce

  1. Put the git repo files in your repository ROOT/{user} catalog
  2. Try to add this repo using UI
  3. Observe the files were removed

Expected behavior

  • Gogs alerts about the path already exists and does nothing more
    OR
  • Gogs merges existing repo files with the "new" repo (less expected for security reasons)

Additional context

UI log message:
An error has occurred : initRepository: initRepository: path already exists: /mnt/Repositories/{user}/{repoName}.git

Test log message:
[ERROR] [...gogs/internal/route/repo/repo.go:100 handleCreateError()] CreatePost: initRepository: initRepository: path already exists: /mnt/Repositories/{user}/{repoName}.git

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added
    💊 bug
    on Jan 9, 2026
  2. changed the title [-]Adding repository which exists in repo ROOT removes it completely[/-] [+]Adding repository which exists in repo ROOT but not in DB removes its files completely[/+] on Jan 9, 2026
  3. changed the title [-]Adding repository which exists in repo ROOT but not in DB removes its files completely[/-] [+]Adding repository which exists in repo ROOT but not in DB removes its files[/+] on Jan 9, 2026
  4. locked as resolved and limited conversation to collaborators on Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    💊 bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions