Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation of a custom plugin fails on linux with different partitions / file systems #3162

Closed
kluba opened this issue Nov 28, 2018 · 6 comments

Comments

Projects
4 participants
@kluba
Copy link

commented Nov 28, 2018

Expected Behavior

dita --install plugin.zip should install a new plugin

Actual Behavior

On linux with several partitions / file systems (/tmp and /home are separated) the command above fails with the following exemplary error message:

Error: /tmp/2913888489706122428/plugin/com.scoop-software.plugin

The class PluginInstallTask tries to move a nonempty directory

Files.move(tempPluginDir.toPath(), pluginDir.toPath());

what does not work if the source and the target are located on different partitions

Possible Solution

I've replaced the Files.move line with the following code:

Files.walkFileTree(tempPluginDir.toPath(), new SimpleFileVisitor<Path>() {

	@Override
	public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
		Path targetPath = pluginDir.toPath().resolve(tempPluginDir.toPath().relativize(dir));
		if(!Files.exists(targetPath)) {
			Files.createDirectory(targetPath);
		}
		return FileVisitResult.CONTINUE;
	}

	@Override
	public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
		Files.copy(file, pluginDir.toPath().resolve(tempPluginDir.toPath().relativize(file)));
		return FileVisitResult.CONTINUE;
	}
});

which fixes the problem on my linux server (and also works on my Windows 10 PC)

Steps to Reproduce

A linux server with two different partitions is needed

  1. Create a new folder on the first partition. Create a file in it
  2. Adopt the paths in the following class. The second path has to point to a different (second) partition
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

public class MoveFailure {
	private static final String tempDir = "/tmp/plugin";
	private static final String homeDir = "/home/user/plugin";
	
	public static void main(String[] args) throws IOException {
            final File tempPluginDir = new File(tempDir);
            final File pluginDir = new File(homeDir);

            Files.move(tempPluginDir.toPath(), pluginDir.toPath());
	}
}
  1. Run the class using java. It results in:
Exception in thread "main" java.nio.file.DirectoryNotEmptyException: /tmp/plugin
        at sun.nio.fs.UnixCopyFile.move(UnixCopyFile.java:498)
        at sun.nio.fs.UnixFileSystemProvider.move(UnixFileSystemProvider.java:262)
        at java.nio.file.Files.move(Files.java:1395)
        at TestMove.main(TestMove.java:17)

Copy of the error message, log file or stack trace

 java.nio.file.DirectoryNotEmptyException: /tmp/2913888489706122428/plugin/com.scoop-software.plugin
     at sun.nio.fs.UnixCopyFile.move(UnixCopyFile.java:498)
     at sun.nio.fs.UnixFileSystemProvider.move(UnixFileSystemProvider.java:262)
     at java.nio.file.Files.move(Files.java:1395)
     at org.dita.dost.ant.PluginInstallTask.execute(PluginInstallTask.java:133)
     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
...

Environment

  • DITA-OT version: 3.2
  • Operating system and version: Linux (SLES 11.4)
  • How did you run DITA-OT: dita command
  • Transformation type: custom (based on PDF)
@hcw70

This comment has been minimized.

Copy link

commented Feb 22, 2019

Affects me too. Because of this we are no longer able to install our plugin.

A fix is needed in order to update to 3.2.1 .....

@hcw70

This comment has been minimized.

Copy link

commented Feb 22, 2019

And that /tmp and /usr (or wherever your dita-install reside) reside on different partitions is quite normal on most linux setups....

@hcw70

This comment has been minimized.

Copy link

commented Feb 22, 2019

@kluba Could you open a merge request, in the hope that any from dita-ot picks up that fix quicker?

@kluba

This comment has been minimized.

Copy link
Author

commented Feb 22, 2019

I've never did that before... But why not. I will try it

@hcw70

This comment has been minimized.

Copy link

commented Feb 22, 2019

This problem was introduced by the pull request #3028 via commit 95385bd. The faulty java implementation was introduced with commit a87bb81 by @jelovirt in file PluginInstallTask.java.

Pls could someone provide a fix for this problem? @kluba provided already some fix proposals for this....

@kluba

This comment has been minimized.

Copy link
Author

commented Feb 22, 2019

@hcw70 I submitted a pull request (#3238)

@jelovirt jelovirt added this to To do in 3.3 via automation Feb 23, 2019

@jelovirt jelovirt moved this from To do to In progress in 3.3 Feb 23, 2019

@infotexture infotexture added this to the 3.3 milestone Feb 27, 2019

3.3 automation moved this from In progress to Done Feb 27, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.