Skip to content
Snippets Groups Projects
Commit b164770c authored by Thomas Mortagne's avatar Thomas Mortagne
Browse files

XWIKI-17457: Filesystem attachments versioning ends up storing 2 copies of the latest version

* fix a potential infinite loop with broken attachments
parent 933bd591
No related branches found
No related tags found
No related merge requests found
......@@ -96,6 +96,9 @@ public static File resolve(File targetFile, boolean followLinks) throws IOExcept
// Stop at the link file if we don't follow it
file = linkFile;
}
} else {
// Stop the loop since no file or link could be found
break;
}
}
......
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.store.filesystem.internal;
import java.io.File;
import java.io.IOException;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertSame;
/**
* Validate {@link StoreFileUtils}.
*
* @version $Id$
*/
class StoreFileUtilsTest
{
@Test
void resolveNotExistingFile() throws IOException
{
File file = new File("does not exist");
assertFalse(file.exists());
File foundFile = StoreFileUtils.resolve(file, true);
assertSame(file, foundFile);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment