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

Enable full feature-set for datalad-annex:: on windows #77

Merged
merged 1 commit into from
Jun 13, 2022
Merged
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
22 changes: 19 additions & 3 deletions datalad_next/gitremote/datalad_annex.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@
from datalad.support.gitrepo import GitRepo
from datalad.support.constraints import EnsureInt
from datalad.ui import ui
from datalad.utils import rmtree
from datalad.utils import (
on_windows,
rmtree,
)

from datalad_next.credman import CredentialManager
from datalad_next.utils import (
Expand Down Expand Up @@ -744,7 +747,20 @@ def replace_remote_deposit_from_mirrorrepo(self):
# update the repo state keys
# it is critical to drop the local keys first, otherwise
# `setkey` below will not replace them with new content
self.log(repoannex.call_annex(['drop', '--force', '--all']))
# however, git-annex fails to do so in some edge cases
# https://git-annex.branchable.com/bugs/Fails_to_drop_key_on_windows___40__Access_denied__41__/?updated
# no regular `drop` works, nor does `dropkeys`
#self.log(repoannex.call_annex(['drop', '--force', '--all']))
# nuclear option remains, luckily possible in this utility repo
if on_windows:
objdir = self.repoannex.dot_git / 'annex' / 'objects'
if objdir.exists():
rmtree(str(objdir), ignore_errors=True)
objdir.mkdir()
else:
# more surgical for the rest
self.log(repoannex.call_annex([
'dropkey', '--force', self.refs_key, self.repo_export_key]))

# use our zipfile wrapper to get an LZMA compressed archive
# via the shutil convenience layer
Expand All @@ -763,7 +779,7 @@ def replace_remote_deposit_from_mirrorrepo(self):
# hand over archive to annex
repoannex.call_annex([
'setkey',
'XDLRA--repo-export',
self.repo_export_key,
archive_file
])
# generate a list of refs
Expand Down
4 changes: 0 additions & 4 deletions datalad_next/gitremote/tests/test_datalad_annex.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
neq_,
rmtree,
serve_path_via_http,
skip_if_on_windows,
SkipTest,
with_tempfile,
)
from datalad.utils import on_windows
Expand Down Expand Up @@ -60,8 +58,6 @@ def eq_dla_branch_state(state, path, branch=DEFAULT_BRANCH):
assert None, f'Could not find state for branch {branch} at {path}'


# https://git-annex.branchable.com/bugs/Fails_to_drop_key_on_windows___40__Access_denied__41__/?updated
@skip_if_on_windows
@with_tempfile
@with_tempfile(mkdir=True)
def test_annex_remote(dspath, remotepath):
Expand Down