Skip to content

Creating a repo locks files when it doesn't need to? #603

@MattSable

Description

@MattSable

I have the following scenario:

  • Init/Clone a repo
  • An exception happens
  • Try to delete the repo during exception handling
  • Get the following error:

The process cannot access the file because it is being used by another process: 'c:\users\testuser\1515512906fdd749\.git\objects\pack\pack-60818aaa1af2cbb2dc09737a822fed53f6ad08be.idx'

I've tried adding this to the exception handling before deleting the repo:

repo = porcelain.open_repo(repo_path)
repo.close()

which works sometimes, but not in all scenarios.

I've found that if I always just close the repo immediately after init/clone, and then just reopen it, I never run into any issues when trying to delete the repo later:

repo = porcelain.init(path)  # or porcelain.clone(...)
repo.close()
repo = porcelain.open_repo(repo.path)

This should mean that one of the two is true:

  1. Init/Clone shouldn't be maintaining the lock on the .idx files, and this is a bug
  2. There are some unintended consequences to my code that I just haven't run into yet.

@jelmer Do you know which of these two is the case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions