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

Update Sync.php #1086

Merged
merged 3 commits into from
Aug 17, 2021
Merged

Update Sync.php #1086

merged 3 commits into from
Aug 17, 2021

Conversation

pchampio
Copy link
Contributor

fixes: #1056

@codecov
Copy link

codecov bot commented Aug 14, 2021

Codecov Report

Merging #1086 (312a801) into master (65383e4) will decrease coverage by 1.75%.
The diff coverage is n/a.

Copy link
Collaborator

@nagmat84 nagmat84 left a comment

Choose a reason for hiding this comment

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

Looks good to me. I recommend one minor improvement to make the code more readable.

$exec->delete_imported = false; // we want to sync -> do not delete imported files
$exec->import_via_symlink = (Configs::get_value('import_via_symlink', '0') === '1');
$exec->skip_duplicates = true;
$exec->delete_imported = $this->option('delete_imported');
Copy link
Collaborator

Choose a reason for hiding this comment

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

I recommend an improvement here in order to avoid coding the same error message "--delete_imported [...] and [...] are conflicting" twice.

First check if ($this->option('import_via_symlink') === '1' && $this->option('delete_imported') === '1') even before you set $exec->delete_imported (i.e. before line 41) and if the condition holds, then bail out with an error message. Then you can be sure, that both options are not set at the same time in the following. This also avoids the nested if below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then you can be sure, that both options are not set at the same time in the following.

If we only check for options with if ($this->option('import_via_symlink') === '1' && $this->option('delete_imported')), how are we dealing with the Config setting (Configs::get_value('import_via_symlink', '0') === '1') == true and $this->option('delete_imported') ?
I've done it this way to make the sync backward compatible so that people using the config import_via_symlink === 1 don't have to add the --import_via_symlink=1 flag.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you push your forked branch patch-1 from the repository pchampio/Lychee as a new branch to LycheeOrg/Lychee? However, I would recommend to rename the branch to something else than patch-1.

Then I could checkout the branch myself and push a commit to show what I mean. I think you don't get the idea.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I took the liberty to push a new commit. I even went beyond my original idea and I added the additional feature that the default values of the command line options are taken from the user configuration.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@pchampio What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is much better!
Thanks, I was looking for a way to set the default values of the command with reference to the configuration, but didn't found how to do it.

@ildyria
Copy link
Member

ildyria commented Aug 15, 2021 via email

@nagmat84
Copy link
Collaborator

Pushing to a new branch on LycheeOrg is not feasible due to access right.

Then I will do it.

@sonarcloud
Copy link

sonarcloud bot commented Aug 15, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Member

@ildyria ildyria left a comment

Choose a reason for hiding this comment

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

LGTM.

@nagmat84
Copy link
Collaborator

LGTM, too. I would approve this PR, too, but it seems that I cannot as a push an own commit (?). I would recommend to wait another day to see whether @pchampio agrees with my changes. If we have no reply by then, we should merge this PR.

@ildyria ildyria merged commit 0a4dfa9 into LycheeOrg:master Aug 17, 2021
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.

[Enhancement] cli sync from from server with option to delete
3 participants