File Operation - Target already exists

I am running a simple test pipeline with only one snap in it and that is File Operation as screenshot below. When I run it, I got “Target already existed” and I am sure the file is not exited in the target

Error

Failed to move from file:///intshare/dev/in/file.txt to file:///intshare/dev/archive/

Resolution:
Address the reported issue.

Reason:
Target already exists
Hide Details…
File Operation[5ee732cd86a4296d121b2640_4964a3d9-e22f-463e-931d-f96f6462929e – 5dc0be59-108e-4169-b8c4-b6ba75c263d9]
com.snaplogic.snap.api.SnapDataException: Failed to move from file:///intshare/dev/in/file.txt to file:///intshare/dev/archive/
at com.snaplogic.snaps.binary.FileOperation.writeError(FileOperation.java:354)
at com.snaplogic.snaps.binary.FileOperation.process(FileOperation.java:321)
at com.snaplogic.snap.api.ExecutionUtil.process(ExecutionUtil.java:106)
at com.snaplogic.snap.api.ExecutionUtil.execute(ExecutionUtil.java:70)
at com.snaplogic.snap.api.SimpleSnap.execute(SimpleSnap.java:70)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.executeSnap(SnapRunnableImpl.java:768)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.execute(SnapRunnableImpl.java:550)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.doRun(SnapRunnableImpl.java:834)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.call(SnapRunnableImpl.java:400)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.call(SnapRunnableImpl.java:116)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.nio.file.FileAlreadyExistsException: /intshare/dev/equifax/edev/archive
at java.base/sun.nio.fs.UnixCopyFile.move(Unknown Source)
at java.base/sun.nio.fs.UnixFileSystemProvider.move(Unknown Source)
at java.base/java.nio.file.Files.move(Unknown Source)
at com.snaplogic.snaps.binary.FileOperation.moveOrCopy(FileOperation.java:387)
at com.snaplogic.snaps.binary.FileOperation.lambda$moveOrCopyFailSafe$1(FileOperation.java:367)
at net.jodah.failsafe.Functions$12.call(Functions.java:274)
at net.jodah.failsafe.SyncFailsafe.call(SyncFailsafe.java:145)
at net.jodah.failsafe.SyncFailsafe.run(SyncFailsafe.java:93)
at com.snaplogic.snaps.binary.BinaryUtils.failsafeExecute(BinaryUtils.java:418)
at com.snaplogic.snaps.binary.FileOperation.moveOrCopyFailSafe(FileOperation.java:368)
at com.snaplogic.snaps.binary.FileOperation.process(FileOperation.java:289)
… 14 more
Reason: Target already exists
Resolution: Address the reported issue.

Error Fingerprint[0] = efp:com.snaplogic.snaps.binary.lZ5uv1uF
Error Fingerprint[1] = efp:sun.nio.fs.2EFCoCmR
File Operation[5ee732cd86a4296d121b2640_4964a3d9-e22f-463e-931d-f96f6462929e – 5dc0be59-108e-4169-b8c4-b6ba75c263d9]
com.snaplogic.cc.snap.common.ThreadDetails: prio=4 Id=130352 RUNNABLE
at com.google.common.base.Throwables.getCausalChain(Throwables.java:303)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.handleException(SnapRunnableImpl.java:969)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.doRun(SnapRunnableImpl.java:855)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.call(SnapRunnableImpl.java:400)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.call(SnapRunnableImpl.java:116)
at java.base@11.0.5/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base@11.0.5/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base@11.0.5/java.util.concurrent.FutureTask.run(Unknown Source)

at com.google.common.base.Throwables.getCausalChain(Throwables.java:303)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.handleException(SnapRunnableImpl.java:969)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.doRun(SnapRunnableImpl.java:855)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.call(SnapRunnableImpl.java:400)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.call(SnapRunnableImpl.java:116)
at java.base@11.0.5/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base@11.0.5/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base@11.0.5/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base@11.0.5/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base@11.0.5/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base@11.0.5/java.lang.Thread.run(Unknown Source)

Error Fingerprint[0] = efp:com.google.common.base.YUdBX85b

The stack trace confirms that the target file already exists. Can you use File Reader or Directory Browser to see if it is correct?

If you want to overwrite the file, you can uncheck “Error if exists”.

If enabled, the Snap throws an error when the target exists. If disabled, the Snap replaces or overwrites the target with the source.

You can see that there is no file in that directory
image

@mtran21, based on the way I understand the File Operation (Snap Behavior for Key Operations section) documentation – for the Move option, it looks like it’s trying to replace the empty folder instead of place the file into the folder. I believe you need to specify the file name in the Target field as well. The Copy operation appears to have the behavior of placing into the folder, like what you’re expecting the Move option to do.

(I haven’t tested either case, but my thought is just based on the documentation)

1 Like