Copied FileAssets not being indexed on copy
This is follow up fix task to: https://github.com/dotCMS/dotCMS/issues/1603
I took the /resources/images folder and copied it into the /images/icons folder. Then I created template with this code:
set($showSubgalleryTitle=false)
set($showPhotoTitle = false)
set ($thumbnailWidth = "150")
set ($thumbnailHeight = "150")
< h1> EXISTING assets
photoGallery("/resources/images")
< h1> COPIED assets
photoGallery("/images/icons/images")
and when I created a new html page with this template, only the existing assets showed but not the copied assets. I had to do a re-index to get them to show. I tested twice... second time on clean dotCMS... clean starter
Here is complete screencast: http://screencast.com/t/6WatHXhja
Oddly enough the fix as implemented works fine on dotcms 2.2 main although to be honest I did use :+1: APILocator.getContentletAPI().refreshContentUnderFolder(newFolder); instead of reindex(structure)....
maybe you could try it with that change and see if it works? and similar logic for BrowserAjax.java: using:
APILocator.getContentletAPI().refreshContentUnderFolder(parent);
I assume that BrowserAjax.java's move() function suffers from the same problems, so I propose adding code to refresh both src and dest folders:
@line 707, new code would be like:
Folder srcFolder = APILocator.getFolderAPI().find(file.getParent(),user,false);
// issues/1603 - refresh index for src Folder
if (srcFolder!=null){
APILocator.getContentletAPI().refreshContentUnderFolder(srcFolder);
}
if ( parent != null ) {
// if copied to a folder, refresh index for that target folder.
APILocator.getContentletAPI().refreshContentUnderFolder(parent);
return APILocator.getFileAPI().moveFile( file, parent, user, false );
} else {
// otherwise refresh content under host
APILocator.getContentletAPI().refreshContentUnderHost(host);
return APILocator.getFileAPI().moveFile( file, host, user, false );
}
....
Don't quote me on this, but it looks logically correct - probably missing something... like refreshing host if srcFolder.getParent() is null... but not sure when/how/if that would occur....
After following the exact same steps, this is stilll not working... created another task here: https://github.com/dotCMS/dotCMS/issues/1736