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

40 local push files from worker fails when cross filesystem #41

Merged
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
7 changes: 5 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"python.linting.enabled": true,
"python.linting.flake8Enabled": false,
"http.systemCertificates": true,
"python.formatting.provider": "black",
"python.formatting.provider": "none",
"files.associations": {
"*.json": "jsonc"
},
Expand All @@ -27,5 +27,8 @@
"python.linting.pylintEnabled": true,
"editor.formatOnType": true,
"python.testing.pytestArgs": [".", "--keepalive"],
"python.linting.pylintCategorySeverity.refactor": "Warning"
"python.linting.pylintCategorySeverity.refactor": "Warning",
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
}
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

# v0.14.3

- Fix issue with local file move when cross filesystem.

# v0.14.2

- Minor log verbosity update
Expand Down
11 changes: 8 additions & 3 deletions src/opentaskpy/remotehandlers/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,22 +181,27 @@
# Get list of files in local_staging_directory
files = glob.glob(f"{local_staging_directory}/*")
for file in files:
self.logger.info(f"[LOCALHOST] Moving file to new location: {file}")
file_name = os.path.basename(file)
final_destination = f"{destination_directory}/{file_name}"
self.logger.info(
f"[LOCALHOST] Moving file to new location: {final_destination}"
)

# Handle any rename that might be specified in the spec
if "rename" in self.spec:
rename_regex = self.spec["rename"]["pattern"]
rename_sub = self.spec["rename"]["sub"]

file_name = re.sub(rename_regex, rename_sub, file_name)
final_destination = f"{destination_directory}/{file_name}"

mode = self.spec["mode"] if "mode" in self.spec else None

try:
os.rename(file, f"{destination_directory}/{file_name}")
shutil.copy(file, final_destination)
os.remove(file)
if mode:
os.chmod(f"{destination_directory}/{file_name}", int(mode))
os.chmod(final_destination, int(mode))

Check warning on line 204 in src/opentaskpy/remotehandlers/local.py

View check run for this annotation

Codecov / codecov/patch

src/opentaskpy/remotehandlers/local.py#L204

Added line #L204 was not covered by tests
except Exception as ex: # pylint: disable=broad-exception-caught
self.logger.error(f"[LOCALHOST] Failed to move file: {ex}")
result = 1
Expand Down
Loading