Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

self.repo.index.remove will occur OSError if creating and renaming quickly #368

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions gitfs/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def _sanitize(self, path):
return path

def push(self, upstream, branch, credentials):
""" Push changes from a branch to a remote
"""Push changes from a branch to a remote

Examples::

Expand All @@ -157,7 +157,7 @@ def fetch(self, upstream, branch_name, credentials):
return behind

def commit(self, message, author, commiter, parents=None, ref="HEAD"):
""" Wrapper for create_commit. It creates a commit from a given ref
"""Wrapper for create_commit. It creates a commit from a given ref
(default is HEAD)
"""

Expand Down Expand Up @@ -423,7 +423,7 @@ def remote_head(self, upstream, branch):
return remote.get_object()

def get_remote(self, name):
""" Retrieve a remote by name. Raise a ValueError if the remote was not
"""Retrieve a remote by name. Raise a ValueError if the remote was not
added to repo

Examples::
Expand Down
13 changes: 9 additions & 4 deletions gitfs/views/current.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ def getattr(self, path, fh=None):
@not_in("ignore", check=["path"])
def write(self, path, buf, offset, fh):
"""
We don't like big big files, so we need to be really carefull
with them. First we check for offset, then for size. If any of this
is off limit, raise EFBIG error and delete the file.
We don't like big big files, so we need to be really carefull
with them. First we check for offset, then for size. If any of this
is off limit, raise EFBIG error and delete the file.
"""

if offset + len(buf) > self.max_size:
Expand Down Expand Up @@ -266,7 +266,12 @@ def _stage(self, message, add=None, remove=None):
path = path.replace("{}/".format(add), "{}/".format(remove))
self.repo.index.remove(path)
else:
self.repo.index.remove(remove)
try:
self.repo.index.remove(remove)
except OSError as e:
log.debug(
"failed to remove from cache: [{}] {}".format(e, type(e))
)
else:
self.repo.index.remove(remove)
non_empty = True
Expand Down