fileCopy from nas to nas

Started by jeg, September 17, 2019, 08:52:17 PM

Previous topic - Next topic

jeg

After the last update (2019.8.4 64 bit) I have trouble with me programs. When I try to copy a file within my nas, I get an error. Copying to me local drive works.
This works

let lquelle="\\\\nas\\temp\\test.md";
let lziel="c:\\temp\\test2.md";
let ergebnis=await IMatch.fileCopy({source:lquelle,target:lziel});

This not

let lquelle="\\\\nas\\temp\\test.md";
let lziel="\\\\nas\\temp\\test2.md";
let ergebnis=await IMatch.fileCopy({source:lquelle,target:lziel});

and I get the error message
the server responded with a status of 500 (Internal Error)

Mario

Check the detailed error info returned by IMWS in the browser debugger or dump it with console.log.
Check the IMatch log file for additional error info. See log file.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

jeg

The log file in debug mode says:

09.18 20:41:51+ 5672 [7B98] 50  M>                    > 19 CIMatchWebServices::HandlerPOST_FSFileCopy  'v:\develop\imatch5\src\imws\imatchwebservices2.cpp(571)'
09.18 20:41:51+  484 [7B98] 50  M>                    < 19 [484ms] CIMatchWebServices::HandlerPOST_FSFileCopy
09.18 20:41:51+   16 [7B98] 50  M>                    > 19 CIMatchWebServices::HandlerPOST_FSFileCopy  'v:\develop\imatch5\src\imws\imatchwebservices2.cpp(571)'
09.18 20:41:51+   47 [7B98] 50  M>                    < 19 [47ms] CIMatchWebServices::HandlerPOST_FSFileCopy

and the debugger in chrome just:

imatchlib.js:387 POST http://127.0.0.1:50519/v1/filesystem/file/copy 500 (Internal Error)

nothing more.
What do you mean with
Quotedetailed error info returned by IMWS ...
? What else can I do?

Mario

#3
Did you check at the entire response?
Usually IMatch returns a detail JSON record in case of a server error.

No exception in the log file so I guess Windows returned an error code.
And the error code and message is included into the details response code, including the main 500 status code.
The Windows shell function IMWS FileCopy uses return a HRESULT and a message (often). These are included in the response.
You can see the entire response in the debugger of your web browser (run your app in the web browser to debug it).
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

jeg

I don't see any additional data, just the error code. See the screenshot of the debugger window.

Mario

Set a breakpoint in the debugger in error(e) => {} handler. Then inspect the response object and look at JSON part. The 500 status code is just the normal HTTP response.

FileCopy....then()
{
}, error => {
console.log(error);
}

The real error message is included in the JSON part of the response.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

jeg

Ok. Here is detailed error result.

"{
"error":{
  "code":1003,
  "message":"Windows COM method or interface failed.",
  {
   "hresult":"80070057",
   "message":"Falscher Parameter."
  }
}
}"

Mario

OK. The Windows shell function for copying files returned

E_INVALIDARG    One or more arguments are not valid    0x80070057

Check the file paths you are using, file system permissions and similar.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

jeg

The rights cannot be a reason, because it is no problem with the Explorer.

C:\>copy c:\temp\readme.md \\nas\temp\readme.md
        1 Datei(en) kopiert.

It looks the same to me.

    var lquelle="c:\\temp\\readme.md";
    var lziel="\\\\nas\\temp\\readme.md";
    IMatch.fileCopy({source:lquelle,target:lziel}).then(function(respononse) {},function(error) { console.log(error)});

Mario

Does you app copy files between folders on your local disk?
If so, the code is OK (and IMWS too) and the problem has somehow to do with your NAS, privileges or similar.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

jeg

When the new Imatch was introduced a few years ago, the old interface was switched off. As a result, I had to rewrite all the programs. Now they run in Javascript/Typescript and I have to rely on simple things like copying a file. If copying on command line works, then from my point of view it's up to Imatch and their implementation.

Mario

Not necessarily.
Command line is a one thing. IMatch uses the Windows shell file system functions internally to copy/move files reliably. The same functions are also used by IMWS.
Hence, if you can copy a file with your code on your local disk, but Windows returns the error code to IMatch when you copy to the NAS, something with the path or security is the problem.

I also have a NAS and I tried to copy files from my local disk to the NAS in an IMatch app. It worked without a problem. But NAS are always special. It depends on so many factors, from the Linux version used to the SAMBA version used to simulate a Windows file system. Much potential for problems.

Can you copy your files in IMatch itself?
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

jeg

Yes. I have registered the target directory and can copy over in IMatch with drag and drop. But the same with fileCopy command from javascript is not possible.

Mario

#13
I have no idea, sorry.
This is basically 5 lines of code in IMWS. Each can fail with a COM error returned by Windows.
But since this never failed before and on your system only fails for the NAS (you did try to copy local files successfully as I suggested above?) I have no further clue which of the Windows functions actually fails.
Two calls process the source/target path and the 3rd call performs the actual copy operation.
I shall add more detailed logging for IMatch 2020. So far this was not needed because there never were any reports.

How many files do you copy? Does the error happen immediately? Local file copy working OK?
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Jingo

Perhaps try a system monitor tool like ProcMon from systools?

Mario

Quote from: Jingo on September 21, 2019, 02:16:45 PM
Perhaps try a system monitor tool like ProcMon from systools?

May be helpful. To monitor the file system calls and maybe catch more error info.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

jeg

In the flood of messages from ProcMon I could not discover anything essential. But then I had an idea. I removed the filename from the target and it worked.

Doesn't work:

var source="c:\\temp\\readme.md";
var target="\\\\nas\\medien_original\\readme.md";

Works

var source="c:\\temp\\readme.md";
var target="\\\\nas\\medien_original";

Works to:

var source="c:\\temp\\readme.md";
var target="c:\\temp\\readme2.md";

It looks like I can't specify a filename when copying to the network.

Mario

-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Mario

I checked the Microsoft documentation but I don't see any specifics about not being able to copy a file under a different name in case of network drives or anything.
The copy function used by IMatch explicitly supports a target file name and, if provided, copies the file under that name.
Maybe your NAS prevents that or does not allow Windows to replace an existing file of the same name or something like that.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

jeg

Sorry, to bother you again. But it seems to be not the solution. My program still doesn't work and I found out, that my the test scenario was misleading. I still can't copy in my network. If I copy direct to the share it works:
Works

source="c:\\temp\\readme.md";
target="\\\\nas\\temp";


Not

source="c:\\temp\\readme.md";
target="\\\\nas\\temp\readme2.md";

error code

"{
"error":{
  "code":1003,
  "message":"Windows COM method or interface failed.",
  {
   "hresult":"80070057",
   "message":"Falscher Parameter."
  }
}
}"


Not

source="c:\\temp\\readme.md";
target="\\\\nas\\temp\\test";

error code
"{
"error":{
  "code":1003,
  "message":"Windows COM method or interface failed.",
  {
   "hresult":"8027000C",
   "message":"Der NapAgent-Dienst wird nicht ausgeführt."
  }
}
}"


If I register the folders in Imatch, I can copy or move them as I like. The same on the command line. Is the internal command to copy by drag&drop the same as the used command for fileCopy?

Mario

Quotetarget="\\\\nas\\temp\readme2.md";

Missing \ in front of readme2.md


Quotetarget="\\\\nas\\temp\\test";

Not a file name.

"message":"Der NapAgent-Dienst wird nicht ausgeführt."

Seems like some service required by Windows is not running?
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

jeg

Quote
Missing \ in front of readme2.md
The test was correct. Only the writing of the answer was incorrect.
Quote
Quote
target="\\\\nas\\temp\\test";

Not a file name.
I know, but with filename I can only copy to the file share itself. But any sub directory is not possible.

But all this is not helping me. I can't copy files and that makes any workflow impossible. But I don't understand how it can be that I can drag and drop files into a directory within IMatch, which is not possible with fileCopy.


Mario

IMatch uses other routines internally than IMWS.
IMWS uses a modern shell interface provided by Windows to copy files.

Judging by the error messages you get (wrong parameter, some service required not missing) I guess this is an isolated issue on your system and with your NAS.
No way for me to diagnose this further. Maybe just copy the files on the command line.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook