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

Test Cp Step #58

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open

Test Cp Step #58

wants to merge 1 commit into from

Conversation

reimic
Copy link
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
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
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
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
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
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
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.

None yet

2 participants