Question:Should deletes via script go to the recycle bin?

Started by ubacher, September 21, 2017, 09:00:59 AM

Previous topic - Next topic

ubacher

 I noticed that deletes from within a script do not go into the recycle bin.
Not sure if that was this way in IM5? Can someone check.
Should they go to the recycle bin? Sure would be better.

Mario

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

ubacher

I found the problem:
In my code I hade a name: argument -- leftover from some copy and paste - which did not cause any errors of any kind!
  IMatch.delete('v1/files', {
                id: ids,
                name: 'unused'
            }).then(function (response) {

Removing the name: 'unused' made the deleted file show up in the wastebasket. Go figure!

(Before it put a temporary file named IMTE031.tmp (Size:0) into the wastebasket.)

Mario

IMWS ignores extraneous parameters.
The DELETE request for /files uses only id/idlist/path, mediaid, partialdelete, deletereadonly.

For security reasons, the endpoint works as follows:

1. It moves the file to delete into the TEMP folder. If this fails, it returns an error.
2. If this works, it removes the file and all associated data from the database.
3. If this works, it deletes the file in the TEMP folder.

if 2. does not work, IMWS rolls back the database transaction and moves the file back from the TEMP folder to the original folder.
It uses a Windows DeleteFile call. There is no documentation that states that this function moves files into the recycle bin.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ubacher

What I thought fixed the problem did not! How the file ended up in the recycle bin in my test I don't know - a fluke?
Repeated this several times since and the deleted file is not put in the recycle bin - but the .tmp file is (an empty file).

If the temp file ends up in the recycle bin it means the windows call does put the file there. Because of the procedure you
described it is clear however that the deleted file does not (since it's moved, renamed and then deleted.)