Skip to content

Test Cp Step#58

Closed
reimic wants to merge 1 commit intoWordPress:trunkfrom
reimic:cp
Closed

Test Cp Step#58
reimic wants to merge 1 commit intoWordPress:trunkfrom
reimic:cp

Conversation

@reimic
Copy link
Copy Markdown
Collaborator

@reimic reimic commented Mar 2, 2024

🚧 Work in progress 🚧

  • TODO affirm it should overwrite newer files:
    Filesystem's copy requires flag overwriteNewerFiles set to true
  • TODO affirm it should copy file to directory
    copy throws an exception when $resolvedToPath is a directory - linux would handle this:
    When the program has one or more arguments of path names of files and following those an argument
    of a path to a directory, then the program copies each source file to the destination directory,
    creating any files not already existing.
  • TODO affirm it should copy all files from one directory to another (also, ponder recursivity)
    copy throws an exception when $resolvedToPath or $resolvedFromPath are directories - linux would
    handle this:
    When the program's arguments are the path names to two directories,
    cp copies all files in the source directory to the destination directory,
    creating any files or directories needed. This mode of operation requires an additional option flag,
    typically r, to indicate the recursive copying of directories.
    If the destination directory already exists, the source is copied into the destination,
    while a new directory is created if the destination does not exist.
  • TODO establish how $input->toPath should be handled
    should copy to document root when null or when ""?

I've pondered it for a moment or two. And I think the right way forward here is to implement our own copy method.

My reasoning:

  • As a user, I'd see a lot of value in using it the way unix specifies it. source
  • Would work more akin to RmStep, handling both files and directories alike.
  • We intend to have a limited amount of steps, so it's not like we'll have a ton of custom methods to maintain.
  • We'll be less reliant on Filesystem, which we must downgrade to v3.x for PHP 7.0.

Currently the cp step copies only form one file path to another (both have to be files).


try {
// TODO affirm it should overwrite newer files
// Filesystem's copy requires flag `overwriteNewerFiles` set to `true`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What are "newer" files? Is the timestamp compared?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes. Excerpt from the Filesystem docs:

If the target file is older than the origin file, it's always overwritten. If the target file is newer, it is overwritten only when the $overwriteNewerFiles option is set to true.

I'd assume the steps should just do as they are told. Therefore, this suggestion.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

yeah, let's ignore the timestamps and just overwrite any pre-existing files

// Filesystem's copy requires flag `overwriteNewerFiles` set to `true`

// TODO affirm it should copy file to directory
// copy throws an exception when $resolvedToPath is a directory - linux would handle this:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yeah that would be useful.

// of a path to a directory, then the program copies each source file to the destination directory,
// creating any files not already existing.

// TODO affirm it should copy all files from one directory to another (also, ponder recursivity)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This would be highly useful as well.

// while a new directory is created if the destination does not exist.

// TODO establish how $input->toPath should be handled
// should copy to document root when null or when ""?
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's assume all the paths are relative to the document root. "" means "document root". null should be rejected during validation and never make it to this function.

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