Third Light Developer Exchange

Code and templating community forum for developers and software integrators

You are not logged in.

Announcement

If you wish to join the Developer Exchange, please contact your account manager - this is to avoid unnecessary spam in the forums. Many thanks for your understanding.

#1 2015-09-01 09:57:12

Andrei_Grosu
Member
Registered: 2014-06-30
Posts: 8

Folders_GetFolderByPath can make folders with same name?

By calling Folders_GetFolderByPath(array("folderPath"=>$folderPath, "createIfNecessary"=>true)) I want to get a folder path or create it if does not exist. The problem is that it seems it created duplicate folders on the 26 august and the same api calls where made for months.  Because my code  run ok for months without any changes i think this is an issue with the JSON API.
I noticed that the server(my customer is Historic Images) is down from time to time or too busy to respond(due to large amount of images being processed) could this make Folders_GetFolderByPath not find folders that exist and create a new one with the same name?

Also do you have an solution to merge the folders(i have lots of subfolders also)?

Offline

#2 2015-09-01 10:25:05

dominic
Third Light Staff
Registered: 2013-06-06
Posts: 119

Re: Folders_GetFolderByPath can make folders with same name?

Hi Andrei,

The server in question unexpectedly lost power on 25th August, which resulted in some database problems. As a result, the folder probably could not be found when your call was performed on 26th August, but was subsequently restored when we repaired the database, leading to the duplicate. As such this is an exceptional occurrence, and not down to your API call or the behaviour of the JSON API itself.

Using the IMS web interface, there is a merge folder tool - although this only merges the files from the immediate folder and not subfolders. The best option would be to use the API; the Folders.CreateFolderPath call accepts a 'parentId' option, relative to which the paths are considered, so you could use this to get or create merge targets from the preferred folder subtree while traversing the children of the duplicate. You could then use Files.Move (which accepts an array of file references) to move the contents to their new destination, and finally remove the unneeded empty folders.

Dominic

Offline

#3 2015-09-01 12:57:56

Andrei_Grosu
Member
Registered: 2014-06-30
Posts: 8

Re: Folders_GetFolderByPath can make folders with same name?

Thanks dominic,

But i've noticed another problem : for some images that my api calls were trying to move i've found duplicates (1 instance in newly created folder and 1 instance in folder from where i was trying to move them). To move the files i use "Files_Move" but it seems that something went pretty wrong on 26 august  because the images from the newly created folders have a newer id(they weren't actually moved) and also the metadata that my api calls were designed to upload them(i only checked a few, can't tell for all).

Can you look at your database restore process to check how came we have those duplicates now?

Also I have an log with the moved images on that date in a database from another server and i can try to redo my process for those images(i first move them from an folder and afterwards upload some metadata to them)  and delete the ones from the newly created structure but i'm not sure if all the images are still in their original folder.  Do you have  any suggestions?

Offline

#4 2015-09-01 13:13:03

dominic
Third Light Staff
Registered: 2013-06-06
Posts: 119

Re: Folders_GetFolderByPath can make folders with same name?

Hi Andrei,

There will only be duplicate files if they have actually been uploaded twice. If you uploaded images on the 26th on account of them not being in the [newly created] folder, but which had previously been uploaded, then that would lead to the effect you describe.

Dominic

Offline

Board footer