Hi,
I had similar problems here. When I renamed the Image Gallery page from the default "Image Gallery" to "Gallery", every time I saved the gallery page it created two additional folders called "Gallery" in the "Files & Images" section. I never got an error message as Terry describes, but I may have manually renamed the folder with album sub folders to "Gallery". I don't remember. Still I got these two additional "Gallery" folders on every save.
I could find a fix that works for my site: I checked the database table ImageGalleryPage (which contains the GalleryPage config settings) and in my case the field RootFolderID had the value '18'. I checked this against the File table which RootFolderID refers to, but there was no entry with ID = '18'. Instead I noticed that the Gallery folder in my case had ID '17'. So all I did was to change ImageGalleryPage.RootFolderID to 17. Now I can save and no new folders are created. Everything works fine. I can add/delete images and albums.
In my case that's sufficient because I only intend to have this one Gallery page anyway. If you want to fix this in your project just make sure that the ID numbers are most likely different, so just double-check.
I don't have a bugfix for the code, but it seems that the unnecessary folders are created in ImageGalleryPage.php, in the ImageGalleryPage class, function checkFolder.
function checkFolder() {
if( ! $this->RootFolderID ) {
$galleries = Folder::findOrMake('image-gallery');
$galleries->Title = 'Image Gallery';
$galleries->write();
$folder = Folder::findOrMake('image-gallery/' . $this->URLSegment);
$folder->Title = $this->Title;
$folder->setName($this->Title);
$folder->write();
$this->RootFolderID = $folder->ID;
$this->write();
$this->requireDefaultAlbum();
FormResponse::add( "\$( 'Form_EditForm' ).getPageFromServer( $this->ID );" );
}
else {
$this->RootFolder()->setName($this->Title);
$this->RootFolder()->write();
}
}
In my case it definitely didn't find the RootFolderID in the highlighted line, so it created a new one. So there seems a little bug that doesn't update or set the RootFolderID correctly somewhere else in the code.
Just to add this to the issue as well. When I create a new album now it creates the folder structure /image-gallery/Gallery/my-album-name/
So my assets folder structure is
- Gallery
-- album1
-- album2
- image-gallery
--Gallery
--- album3
(I created album1 and album2 before I renamed the gallery page from "Image Gallery" to "Gallery".)
This is not a big issue and I could probably just recreate album 1 and album 2 and delete the old ones if I feel the assets structure is so important, but just to make people aware. The whole thing is probably just a small issue to fix, but I couldn't find a solution yet.
Cheers!
Anatol