@@ -83,10 +83,10 @@ public MountBuilder setMountpoint(Path mountPoint) {
83
83
public MountBuilder setLoopbackHostName (String hostName ) {
84
84
this .hostName = hostName ;
85
85
try {
86
- Path .of ("\\ \\ " + hostName + "\\ share" );
87
- new URL ("http" ,hostName ,80 ,"/" );
86
+ Path .of ("\\ \\ " + hostName + "\\ share" );
87
+ new URL ("http" , hostName , 80 , "/" );
88
88
} catch (MalformedURLException | InvalidPathException e ) {
89
- throw new IllegalArgumentException ("hostName \" " + hostName + "\" does not satifsfy OS restrictions." ,e );
89
+ throw new IllegalArgumentException ("hostName \" " + hostName + "\" does not satifsfy OS restrictions." , e );
90
90
}
91
91
return this ;
92
92
}
@@ -109,8 +109,8 @@ protected Mount mount(WebDavServerHandle serverHandle, WebDavServletController s
109
109
tuneProxyConfigSilently (uri );
110
110
String mountPoint = driveLetter == null //
111
111
? SYSTEM_CHOSEN_MOUNTPOINT // MOUNT_TO_SYSTEM_CHOSEN_PATH
112
- : driveLetter .toString (); // MOUNT_AS_DRIVE_LETTER
113
- String uncPath = "\\ \\ " + (hostName == null ? uri .getHost () : hostName ) + "@" + uri .getPort () + uri .getRawPath ().replace ('/' , '\\' );
112
+ : driveLetter .toString (). substring ( 0 , 2 ) ; // MOUNT_AS_DRIVE_LETTER
113
+ String uncPath = "\\ \\ " + (hostName == null ? uri .getHost () : hostName ) + "@" + uri .getPort () + uri .getRawPath ().replace ('/' , '\\' );
114
114
ProcessBuilder mount = new ProcessBuilder ("net" , "use" , mountPoint , uncPath , "/persistent:no" );
115
115
Process mountProcess = mount .start ();
116
116
ProcessUtil .waitFor (mountProcess , 30 , TimeUnit .SECONDS );
@@ -125,7 +125,7 @@ protected Mount mount(WebDavServerHandle serverHandle, WebDavServletController s
125
125
}
126
126
127
127
LOG .debug ("Mounted {} on drive {}" , uncPath , actualMountpoint );
128
- return new MountImpl (serverHandle , servlet , actualMountpoint );
128
+ return new MountImpl (serverHandle , servlet , actualMountpoint , uncPath );
129
129
} catch (IOException | TimeoutException e ) {
130
130
throw new MountFailedException (e );
131
131
}
@@ -167,7 +167,7 @@ private static void tuneProxyConfigSilently(URI uri) {
167
167
168
168
/**
169
169
* @param uri The URI for which to tune the registry settings
170
- * @throws IOException If registry access fails
170
+ * @throws IOException If registry access fails
171
171
* @throws TimeoutException If registry access does not finish in time
172
172
* @deprecated TODO overheadhunter: check if this is really necessary.
173
173
*/
@@ -205,13 +205,15 @@ private static class MountImpl extends AbstractMount {
205
205
private final ProcessBuilder forcedUnmountCommand ;
206
206
207
207
private final Path mountpoint ;
208
+ private final String uncPath ;
208
209
private final AtomicBoolean isUnmounted ;
209
210
210
- public MountImpl (WebDavServerHandle serverHandle , WebDavServletController servlet , String driveLetter ) {
211
+ public MountImpl (WebDavServerHandle serverHandle , WebDavServletController servlet , String driveLetter , String uncPath ) {
211
212
super (serverHandle , servlet );
212
213
this .unmountCommand = new ProcessBuilder ("net" , "use" , driveLetter , "/delete" , "/no" );
213
214
this .forcedUnmountCommand = new ProcessBuilder ("net" , "use" , driveLetter , "/delete" , "/yes" );
214
215
this .mountpoint = Path .of (driveLetter + "\\ " );
216
+ this .uncPath = uncPath ;
215
217
this .isUnmounted = new AtomicBoolean (false );
216
218
}
217
219
@@ -267,9 +269,6 @@ private synchronized void unmount(ProcessBuilder command) throws UnmountFailedEx
267
269
@ SuppressWarnings ("resource" )
268
270
private boolean isUnmounted () {
269
271
try {
270
- var uri = servlet .getServletRootUri ();
271
- String uncPath = "\\ \\ " + uri .getHost () + "@" + uri .getPort () + uri .getRawPath ().replace ('/' , '\\' );
272
-
273
272
ProcessBuilder determineMP = new ProcessBuilder ("net" , "use" );
274
273
Process determineMPProcess = ProcessUtil .startAndWaitFor (determineMP , 5 , TimeUnit .SECONDS );
275
274
ProcessUtil .assertExitValue (determineMPProcess , 0 );
0 commit comments