BaseXdb / basex

BaseX Main Repository.
http://basex.org
BSD 3-Clause "New" or "Revised" License
678 stars 268 forks source link

file:copy() function doesn't copy the same directory more than once #2135

Closed s0rr0w closed 2 years ago

s0rr0w commented 2 years ago

Description of the Problem

Hello BaseX team!

The file:copy() function works not as it described in the documentation

Copies a file or directory specified by $source to the file or directory specified by $target. If the target file already exists, it will be overwritten. No operation will be performed if the source and target path are equal.

When you run the following script twice BaseX returns the next error message with its code

[file:is-dir] '/Users/user/target/2' is a directory.

The code

let $d1 := file:create-dir("./1")
let $d2 := file:create-dir("./1/2")
let $d3 := file:create-dir("./target")
let $f := file:write-text("./1/2/3.txt","Hey!")
for $i in file:children("./1")
return
    file:copy($i,"./target")

Expected Behavior

No errors

Steps to Reproduce the Behavior

  1. Run the script
  2. Run the script again

Do you have an idea how to solve the issue?

No response

What is your configuration?

java -version
openjdk version "11.0.16" 2022-07-19
OpenJDK Runtime Environment Temurin-11.0.16+8 (build 11.0.16+8)
OpenJDK 64-Bit Server VM Temurin-11.0.16+8 (build 11.0.16+8, mixed mode)

Launch script java -cp BaseX100.jar:./lib/* org.basex.BaseXGUI Libraries

$ ls lib
tagsoup-1.2.1.jar

MacOS Big Sur 11.6.8

ChristianGruen commented 2 years ago

Thanks for the report. The bug has been fixed, and a new snapshot is available.