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

add no overwrite feature #9

Merged
merged 2 commits into from
Mar 1, 2024
Merged

add no overwrite feature #9

merged 2 commits into from
Mar 1, 2024

Conversation

sparul93
Copy link
Member

@sparul93 sparul93 commented Mar 1, 2024

Add no-file overwrite feature, check if the feature is enable/disabled and if the file in question exists on the destination server.

@sparul93 sparul93 requested a review from orlund March 1, 2024 16:43
# No overwrite feature
# Check the environment variable status and if the file exists
if file_overwrite.upper() == "NO" and to_fs.exists(path):
try:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than using an exception to break the loop and continue code something like below might work,
I think something like this would also prevent output form lines 167-168 (which are probably irrelevant in this case)
and the debug output should change a little because it might not all files not being transferred but just specific ones not transferred because of overwriting.

            logger.debug(
                f"File overwrite is disabled. \nFile {path} not transferred"
            )
            break

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orlund Hey Orlund, so break stops the entire for loop and does not allow the code to execute further. I have used pass instead.
Testing was successful as well:
smb://svc_bank_recon_jde:[email protected]:445/groups/OWIFACE/bank_reconciliation_to_jde/jde_test/
sftp://filepass:[email protected]:22/u01/jdedwards/e910/PY910/import/
Establishing smb connection from server: dept-fs-pv03.ad.kamloops.city
Directory: /OWIFACE/bank_reconciliation_to_jde/jde_test/
Establishing sftp connection from server: jdeenttsvr.kamloops.city
Directory: /u01/jdedwards/e910/PY910/import/
File to move: /bank_recon_test.txt
No delete (to): /bank_recon_test.txt
No delete (from): /bank_recon_test.txt
File to move: /bank_recon_test2.txt
No delete (to): /bank_recon_test2.txt
File overwrite is disabled.
File /bank_recon_test2.txt not transferred
File to move: /bank_recon_test3.txt
No delete (to): /bank_recon_test3.txt
No delete (from): /bank_recon_test3.txt

@sparul93 sparul93 requested a review from orlund March 1, 2024 21:41
Copy link
Member

@orlund orlund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

@sparul93 sparul93 merged commit df86c89 into main Mar 1, 2024
2 checks passed
@sparul93 sparul93 deleted the bank-recon-file-overwrite branch March 1, 2024 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants