Skip to content

Display information when downloading a file.#65

Merged
webflo merged 8 commits into
drupal-composer:masterfrom
FlorentTorregrosa:download_info
Dec 25, 2017
Merged

Display information when downloading a file.#65
webflo merged 8 commits into
drupal-composer:masterfrom
FlorentTorregrosa:download_info

Conversation

@FlorentTorregrosa

Copy link
Copy Markdown
Contributor

Currently when downloading files, the command line displays a concatenated string of "Downloading: 100%" which is not helpful to see which file is downloaded where and which file fails downloading in case of failure.

Here is some code to improve the output of the command line.

Thanks for the review.

@T2L

T2L commented Jun 29, 2017

Copy link
Copy Markdown

Also, it would be great if we can respect --no-progress composer option and skip showing this information at all.

@T2L

T2L commented Jun 29, 2017

Copy link
Copy Markdown

I've checked the output. I my opinion it generates too much noise (and new lines). Suggestions:

  • combine into a single line (as composer does with vendor dependencies)
  • add colors

@webflo

webflo commented Jun 30, 2017

Copy link
Copy Markdown
Member

Hi, i think the proposed changes by @T2L are valid. @FlorentTorregrosa do you want to change the PR accordingly?

@FlorentTorregrosa

Copy link
Copy Markdown
Contributor Author

Hello,

Thanks both for your feedback. I will try to change the pull request accordingly. I also think that it would be nice to add colors and to do as composer does, I currently don't know how to do that. That's why I didn't do that before. I will search for that.

I don't know when I would have time to update my PR.

Also if I can have a feedback on #58 because all concerns where addressed, it would be nice so if something needs to be changed I will do it when I will (re-)dig into composer.

@FlorentTorregrosa

Copy link
Copy Markdown
Contributor Author

Hello,

I have updated the pull request with the suggestions and fixed the tests.

Is it ok now to be merged?

array_walk($this->filenames, function ($filename) use ($version, $destination, &$requests) {
$url = $this->getUri($filename, $version);
$this->fs->ensureDirectoryExists($destination . '/' . dirname($filename));
$requests[] = new CopyRequest($url, $destination . '/' . $filename, false, $this->io, $this->config);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think, we can skip this hunk and add the information in line 65.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@webflo Thanks for your review.
At line 65, the $filename variable is not defined. So should I remove lines 40 to 49 and use the previous line 46? And leave line 65 as it is?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Seen with @greg-1-anderson. Will update the pull request.

@FlorentTorregrosa

Copy link
Copy Markdown
Contributor Author

Saw with @greg-1-anderson, I will refactor FileFetcher, InitialFileFetcher and PrestissimoFileFetcher to avoid code duplication and to use Prestissimo for initial file fetching.

@clemens-tolboom

Copy link
Copy Markdown

I was about to submit a PR way worse then this one. 👍

I learned drupal-scaffold is fetching the d.o. files and it's good to know these are fetched and when refetching with composer run-script 'drupal-scaffold'.

@FlorentTorregrosa

Copy link
Copy Markdown
Contributor Author

Hello,

The refactoring has been done. Thanks for the review.

Comment thread src/FileFetcher.php Outdated
public function fetch($version, $destination, $erase) {
foreach ($this->filenames as $sourceFilename => $filename) {
$target = "$destination/$filename";
if ($erase || !file_exists($target)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

So this does not fetch a file when already existing.

That sounds bad to me. Ie a new default.settings.php or .htaccess fixing a security issue I definitely want that downloaded when updating a project.

@FlorentTorregrosa FlorentTorregrosa Oct 11, 2017

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It fetches a file even if it already exists because in https://github.com/drupal-composer/drupal-scaffold/pull/65/files#diff-bb433a78829fe2e46d711575194d4f50R140 we use the $erase parameter to TRUE and only $erase to FALSE when using it for the initial fetch https://github.com/drupal-composer/drupal-scaffold/pull/65/files#diff-bb433a78829fe2e46d711575194d4f50R143

In the README.md:
The initial hash lists files that should be copied over only if they do not exist in the destination. The key specifies the path to the source file, and the value indicates the path to the destination file.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I was referring @ the code lines changed. I should have dug deeper. Sorry

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No problem. Thanks for the review.

@FlorentTorregrosa

Copy link
Copy Markdown
Contributor Author

Hello,

I have rebased my changes to followup the last code changes in drupal-scaffold.

Would it be possible to have a review please?

@webflo

webflo commented Dec 23, 2017

Copy link
Copy Markdown
Member

The $erase parameter is new feature? It was don't there before.

@FlorentTorregrosa

Copy link
Copy Markdown
Contributor Author

Hello,

The $erase is not a new feature, it was introduced to refactor the FileFetcher and the initialFileFetcher classes. Therefore the initial fetch also benefits from the PrestissimoFileFetcher.

@webflo

webflo commented Dec 24, 2017

Copy link
Copy Markdown
Member

Alright, i understand it has been a while since i looked at the code. Lets rename it to $override? I thinks this is a better fit.

@FlorentTorregrosa

Copy link
Copy Markdown
Contributor Author

OK. I have changed the name of the variable.

@webflo webflo merged commit 215ffb3 into drupal-composer:master Dec 25, 2017
@webflo

webflo commented Dec 25, 2017

Copy link
Copy Markdown
Member

Merged.

@FlorentTorregrosa thanks 👍

@FlorentTorregrosa

FlorentTorregrosa commented Dec 25, 2017

Copy link
Copy Markdown
Contributor Author

\o/ Thanks!!! Finally merged 🎁 🎄 🎁. It's Christmas magic :D

Next steps:

@FlorentTorregrosa FlorentTorregrosa deleted the download_info branch December 25, 2017 11:20
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.

4 participants