Community
Participate
Working Groups
Build Identifier: Version: 3.6.1 Publish helper's approach to moving files during publishing does not work when publishing to a path on a different device. The publish moves file from .metadata/.plugins/org.eclipse.jst.server.generic.core/tmp directory to a directory supplied in AbstractModuleAssembler.Factory .getModuleAssembler(module, getServer(), p); The offending code is in PublishHelper.moveTempFile(File tempFile, File file) method. /** * Utility method to move a temp file into position by deleting the original and * swapping in a new copy. * * @param tempFile * @param file * @throws CoreException */ private void moveTempFile(File tempFile, File file) throws CoreException { if (file.exists()) { if (!safeDelete(file, 2)) { // attempt to rewrite an existing file with the tempFile contents if // the existing file can't be deleted to permit the move try { InputStream in = new FileInputStream(tempFile); IStatus status = copyFile(in, file.getPath()); if (!status.isOK()) { MultiStatus status2 = new MultiStatus(ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, file.toString()), null); status2.add(status); throw new CoreException(status2); } return; } catch (FileNotFoundException e) { // shouldn't occur } finally { tempFile.delete(); } /*if (!safeDelete(file, 8)) { tempFile.delete(); throw new CoreException(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, file.toString()), null)); }*/ } } if (!safeRename(tempFile, file, 10)) throw new CoreException(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorRename, tempFile.toString()), null)); } Reproducible: Always Steps to Reproduce: 1. Create a custom Publisher 2. In that publisher create an AbstractModuleAssembler using AbstractModuleAssembler.Factory .getModuleAssembler(IModule module, GenericServer server, IPath path); 3. publish a webapp via Eclipse.
Hi Tundra: If you mean the class PublishHelper in org.eclipse.wst.server.core.util package, then this is a ServerTools bug and needs to be brought up there. For what it's worth, I do remember that one way to properly fix this is to make sure your temporary file is on the same device and filesystem as your destination file. The PublishHelper class actually takes a temporary directory in it's constructor to allow you to do this. A stacktrace of the failure would definitely be helpful... It's possible there's a slight API deficiency for users looking to make use of this functionality, but after reviewing the code, I suspect all that you'd need to make use of is currently already available to you. Routing over to servertools
I recall we had some problems around this area a few years ago. Not sure if we did fixed it or not. Tim, Do you recall what happened to the moving/copy of files to a different device? Did we fixed it? I will see if I can find the bug.
Rob is correct - it is the job of whoever creates the publish util/helper (looks like generic server in this case) to use a temp folder on the target device, typically relative or near to the final publishing folder. If the publish helper is created without a temp folder or not on the drive/device it is publishing to, we'd expect a failure like this on *nix.
Moving out of 3.3 as we are almost done with it. Marking for future until we have a more accurate time when we can work on this.