This is an automated email from the ASF dual-hosted git repository. jleroux pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
commit f81bd885257dfeef35508c16787f0e889ae09c74 Author: Jacques Le Roux <[email protected]> AuthorDate: Fri Nov 27 11:47:57 2020 +0100 Reverted: Replace java.io.File::renameTo by java.nio.file.Files::move (OFBIZ-12063) This reverts commit 2c86f9a8c0219fe8779dcb5620ee29e3efa1df86. Actually the problem was due to another WIP where 2 streams were not closed --- .../groovyScripts/catalog/product/EditProductContent.groovy | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/applications/product/groovyScripts/catalog/product/EditProductContent.groovy b/applications/product/groovyScripts/catalog/product/EditProductContent.groovy index e180352..f4b1fe8 100644 --- a/applications/product/groovyScripts/catalog/product/EditProductContent.groovy +++ b/applications/product/groovyScripts/catalog/product/EditProductContent.groovy @@ -113,8 +113,8 @@ if (fileType) { imageUrl = imageUrlPrefix + "/" + filePathPrefix + java.net.URLEncoder.encode(filenameToUse, characterEncoding) try { - defaultFile = new File(imageServerPath + "/" + filePathPrefix, defaultFileName) - fileToUse = new File(imageServerPath + "/" + filePathPrefix, filenameToUse) + file = new File(imageServerPath + "/" + filePathPrefix, defaultFileName) + file1 = new File(imageServerPath + "/" + filePathPrefix, filenameToUse) try { // Delete existing image files File targetDir = new File(imageServerPath + "/" + filePathPrefix) @@ -138,9 +138,8 @@ if (fileType) { } catch (Exception e) { logError(e, "error deleting existing file (not neccessarily a problem)") } - // OFBIZ-12063: on Windows neither file.renameTo(), Files.move() nor FileUtils.moveFile() works - Files.copy(defaultFile.toPath(), fileToUse.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING) - defaultFile.delete(); + Path source = file.toPath() + Files.move(source, source.resolveSibling(filenameToUse)) } catch (Exception e) { logError(e, module) }

