xproc / 3.0-steps

Repository for change requests to the standard step library and for official extension steps
10 stars 7 forks source link

More clarification needed on p:file-copy and file-move #433

Closed xml-project closed 4 years ago

xml-project commented 4 years ago

[I numbered the single aspects, so it is easier to comment on single points.]

  1. I already proposed to have an additional option named "override" or "override-target" which, when false, prevents any existing file resource from being overriden.
  2. Apart from that I think the behaviour of these two steps is only well-defined for the case both the source and the target is a file. For a file source and a folder target we say, that the file source is copied into the folder. This seems right to me.
  3. I think that we need to say that it is an error if the source names a folder but the target names a file. I cannot see how to make sense out it.
  4. The forth case where the source and the target names a folders is not covered at all to my reading. The options are that all content IN the source folder is copied into the target folder or that a copy of the source folder in created in the target folder. I would expect the first behaviour, but are surely open to arguments.

Was I able to make my points? Did I miss something?

ndw commented 4 years ago
  1. How about "overwrite" rather than override? Defaulting to true?
  2. For two files or for a file into a folder, those make sense to me.
  3. Yes, error makes sense here.
  4. Error?
xatapult commented 4 years ago

About 4:

Assume you're trying to copy (source) directory /something/x/ to (target) /something/y/. Wouldn't it make sense that a directory /something/y/x/ is created, including the full file/sub-directory structure of the source underneath?

ndw commented 4 years ago

As Achim said, that's one of two plausible expectations. Error means we don't have to choose one :-)

xatapult commented 4 years ago

We agree on this:

Assume you're trying to copy (source) directory /something/x/ to (target) /something/y/. Wouldn't it make sense that a directory /something/y/x/ is created, including the full file/sub-directory structure of the source underneath?

xml-project commented 4 years ago

Resolved for p:file-copy, but still open for p:file-move. See #354

xml-project commented 4 years ago

Here is why I think somebody else should step in: Suppose with the following folder structure (y and y and z and z are files with the same name. I use * just to mark there origin):

a                   b
    - x             -a
    - y*                   -v   
    - z*                   -y
                           -z

With overwrite = "true" b is:

b
    -a
        -x
        -v
        -y*
        -z*

And a does not exist anymore.

Now with overwrite="false" this has to be an error, because of y and z. So the state of a and b after p:file-move will be

 a              b
    -y*             -a
    -z*                 -x
                                             -v
                         -y
                         -z

Right? And this is exactly what I fail to describe.

ndw commented 4 years ago

If a and b are files, move a b is the same as delete b; rename a b.

If a is a file and b is a folder, I think we decided that we would try to be consistent with what filesystems do. In this case move a b is the same as delete b/a; rename a b/a.

I think that should be true if a is a folder as well.

Does that help?

(By the way, I'm happy to help write it, but I think we're still trying to clarify what the actual semantics are. There's no way to write prose we'll all agree with if we have different interpretations of what we should be describing!)

xml-project commented 4 years ago

But then the semantic of overwrite is different for p:file-move and p:file-copy would be very different. For overwrite = false it would be: if (exists(b)) then error else delete b; rename a b. If it is only this, I would opt to leave "overwrite" out for p:file-move because this can be done with XProc is alone in an effective way.

(By the way, I'm happy to help write it, but I think we're still trying to clarify what the actual semantics are. There's no way to write prose we'll all agree with if we have different interpretations of what we should be describing!)

Thanks.