Lines 50-55
Link Here
|
50 |
import java.io.InputStream; |
50 |
import java.io.InputStream; |
51 |
import java.io.InterruptedIOException; |
51 |
import java.io.InterruptedIOException; |
52 |
import java.io.OutputStream; |
52 |
import java.io.OutputStream; |
|
|
53 |
import java.io.PrintWriter; |
53 |
import java.lang.ref.Reference; |
54 |
import java.lang.ref.Reference; |
54 |
import java.lang.ref.SoftReference; |
55 |
import java.lang.ref.SoftReference; |
55 |
import java.net.ConnectException; |
56 |
import java.net.ConnectException; |
Lines 70-75
Link Here
|
70 |
import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment; |
71 |
import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment; |
71 |
import org.netbeans.modules.nativeexecution.api.util.CommonTasksSupport; |
72 |
import org.netbeans.modules.nativeexecution.api.util.CommonTasksSupport; |
72 |
import org.netbeans.modules.nativeexecution.api.util.ConnectionManager; |
73 |
import org.netbeans.modules.nativeexecution.api.util.ConnectionManager; |
|
|
74 |
import org.netbeans.modules.nativeexecution.api.util.FileInfoProvider; |
75 |
import org.netbeans.modules.nativeexecution.api.util.FileInfoProvider.StatInfo; |
73 |
import org.netbeans.modules.nativeexecution.api.util.ProcessUtils; |
76 |
import org.netbeans.modules.nativeexecution.api.util.ProcessUtils; |
74 |
import org.netbeans.modules.remote.support.RemoteLogger; |
77 |
import org.netbeans.modules.remote.support.RemoteLogger; |
75 |
import org.openide.filesystems.FileEvent; |
78 |
import org.openide.filesystems.FileEvent; |
Lines 112-118
Link Here
|
112 |
|
115 |
|
113 |
/*package*/ boolean canWrite(String childNameExt) throws IOException, ConnectException { |
116 |
/*package*/ boolean canWrite(String childNameExt) throws IOException, ConnectException { |
114 |
try { |
117 |
try { |
115 |
DirectoryStorage storage = getDirectoryStorage(); |
118 |
DirectoryStorage storage = getDirectoryStorage(childNameExt); |
116 |
DirEntry entry = storage.getEntry(childNameExt); |
119 |
DirEntry entry = storage.getEntry(childNameExt); |
117 |
return entry != null && entry.canWrite(getExecutionEnvironment()); //TODO:rfs - check groups |
120 |
return entry != null && entry.canWrite(getExecutionEnvironment()); //TODO:rfs - check groups |
118 |
} catch (ConnectException ex) { |
121 |
} catch (ConnectException ex) { |
Lines 133-139
Link Here
|
133 |
|
136 |
|
134 |
/*package*/ boolean canRead(String childNameExt) throws IOException { |
137 |
/*package*/ boolean canRead(String childNameExt) throws IOException { |
135 |
try { |
138 |
try { |
136 |
DirectoryStorage storage = getDirectoryStorage(); |
139 |
DirectoryStorage storage = getDirectoryStorage(childNameExt); |
137 |
DirEntry entry = storage.getEntry(childNameExt); |
140 |
DirEntry entry = storage.getEntry(childNameExt); |
138 |
return entry != null && entry.canRead(getExecutionEnvironment()); |
141 |
return entry != null && entry.canRead(getExecutionEnvironment()); |
139 |
} catch (ConnectException ex) { |
142 |
} catch (ConnectException ex) { |
Lines 271-277
Link Here
|
271 |
} |
274 |
} |
272 |
RemoteLogger.assertTrue(slashPos == -1); |
275 |
RemoteLogger.assertTrue(slashPos == -1); |
273 |
try { |
276 |
try { |
274 |
DirectoryStorage storage = getDirectoryStorage(); |
277 |
DirectoryStorage storage = getDirectoryStorage(relativePath); |
275 |
DirEntry entry = storage.getEntry(relativePath); |
278 |
DirEntry entry = storage.getEntry(relativePath); |
276 |
if (entry == null) { |
279 |
if (entry == null) { |
277 |
return null; |
280 |
return null; |
Lines 385-393
Link Here
|
385 |
|
388 |
|
386 |
private DirectoryStorage getDirectoryStorage() throws |
389 |
private DirectoryStorage getDirectoryStorage() throws |
387 |
ConnectException, IOException, InterruptedException, CancellationException, ExecutionException { |
390 |
ConnectException, IOException, InterruptedException, CancellationException, ExecutionException { |
|
|
391 |
return getDirectoryStorage(null); |
392 |
} |
393 |
|
394 |
private DirectoryStorage getDirectoryStorage(String childName) throws |
395 |
ConnectException, IOException, InterruptedException, CancellationException, ExecutionException { |
388 |
long time = System.currentTimeMillis(); |
396 |
long time = System.currentTimeMillis(); |
389 |
try { |
397 |
try { |
390 |
return getDirectoryStorageImpl(false, null); |
398 |
return getDirectoryStorageImpl(false, null, childName); |
391 |
} finally { |
399 |
} finally { |
392 |
if (trace) { |
400 |
if (trace) { |
393 |
trace("getDirectoryStorage for {1} took {0} ms", this, System.currentTimeMillis() - time); // NOI18N |
401 |
trace("getDirectoryStorage for {1} took {0} ms", this, System.currentTimeMillis() - time); // NOI18N |
Lines 399-405
Link Here
|
399 |
ConnectException, IOException, InterruptedException, CancellationException, ExecutionException { |
407 |
ConnectException, IOException, InterruptedException, CancellationException, ExecutionException { |
400 |
long time = System.currentTimeMillis(); |
408 |
long time = System.currentTimeMillis(); |
401 |
try { |
409 |
try { |
402 |
return getDirectoryStorageImpl(true, expectedName); |
410 |
return getDirectoryStorageImpl(true, expectedName, null); |
403 |
} finally { |
411 |
} finally { |
404 |
if (trace) { |
412 |
if (trace) { |
405 |
trace("refreshDirectoryStorage for {1} took {0} ms", this, System.currentTimeMillis() - time); // NOI18N |
413 |
trace("refreshDirectoryStorage for {1} took {0} ms", this, System.currentTimeMillis() - time); // NOI18N |
Lines 407-413
Link Here
|
407 |
} |
415 |
} |
408 |
} |
416 |
} |
409 |
|
417 |
|
410 |
private DirectoryStorage getDirectoryStorageImpl(boolean force, String expectedName) throws |
418 |
private DirectoryStorage getDirectoryStorageImpl(boolean force, String expectedName, String childName) throws |
411 |
ConnectException, IOException, InterruptedException, CancellationException, ExecutionException { |
419 |
ConnectException, IOException, InterruptedException, CancellationException, ExecutionException { |
412 |
|
420 |
|
413 |
if (force && ! ConnectionManager.getInstance().isConnectedTo(getExecutionEnvironment())) { |
421 |
if (force && ! ConnectionManager.getInstance().isConnectedTo(getExecutionEnvironment())) { |
Lines 503-513
Link Here
|
503 |
throw new IOException("Can not create cache directory " + getCache()); // NOI18N |
511 |
throw new IOException("Can not create cache directory " + getCache()); // NOI18N |
504 |
} |
512 |
} |
505 |
} |
513 |
} |
506 |
DirectoryReader directoryReader = getLsViaSftp() ? |
514 |
List<DirEntry> readEntries = new ArrayList<DirEntry>(); |
507 |
new DirectoryReaderSftp(getExecutionEnvironment(), getPath()) : new DirectoryReaderLs(getExecutionEnvironment(), getPath()); |
|
|
508 |
if (trace) { trace("synchronizing"); } // NOI18N |
515 |
if (trace) { trace("synchronizing"); } // NOI18N |
509 |
try { |
516 |
try { |
510 |
directoryReader.readDirectory(); |
517 |
if (canRead()) { |
|
|
518 |
DirectoryReader directoryReader = getLsViaSftp() ? |
519 |
new DirectoryReaderSftp(getExecutionEnvironment(), getPath()) : new DirectoryReaderLs(getExecutionEnvironment(), getPath()); |
520 |
directoryReader.readDirectory(); |
521 |
readEntries = directoryReader.getEntries(); |
522 |
} else { |
523 |
if (childName != null) { |
524 |
Future<StatInfo> stat = FileInfoProvider.stat(getExecutionEnvironment(), getPath() + '/' + childName, new PrintWriter(System.err)); |
525 |
DirEntry entry = new DirEntrySftp(stat.get(), childName); |
526 |
readEntries.add(entry); |
527 |
} |
528 |
} |
511 |
} catch (FileNotFoundException ex) { |
529 |
} catch (FileNotFoundException ex) { |
512 |
throw ex; |
530 |
throw ex; |
513 |
} catch (IOException ex) { |
531 |
} catch (IOException ex) { |
Lines 537-544
Link Here
|
537 |
getFileSystem().incrementDirSyncCount(); |
555 |
getFileSystem().incrementDirSyncCount(); |
538 |
Map<String, List<DirEntry>> dupLowerNames = new HashMap<String, List<DirEntry>>(); |
556 |
Map<String, List<DirEntry>> dupLowerNames = new HashMap<String, List<DirEntry>>(); |
539 |
boolean hasDups = false; |
557 |
boolean hasDups = false; |
540 |
Map<String, DirEntry> newEntries = new HashMap<String, DirEntry>(); |
558 |
Map<String, DirEntry> newEntries = new HashMap<String, DirEntry>(); |
541 |
for (DirEntry entry : directoryReader.getEntries()) { |
559 |
for (DirEntry entry : readEntries) { |
542 |
newEntries.put(entry.getName(), entry); |
560 |
newEntries.put(entry.getName(), entry); |
543 |
} |
561 |
} |
544 |
boolean changed = (newEntries.size() != storage.size()); |
562 |
boolean changed = (newEntries.size() != storage.size()); |
Lines 679-685
Link Here
|
679 |
lock.unlock(); |
697 |
lock.unlock(); |
680 |
} |
698 |
} |
681 |
checkConnection(child, true); |
699 |
checkConnection(child, true); |
682 |
DirectoryStorage storage = getDirectoryStorage(); // do we need this? |
700 |
DirectoryStorage storage = getDirectoryStorage(child.getNameExt()); // do we need this? |
683 |
return new CachedRemoteInputStream(child, getExecutionEnvironment()); |
701 |
return new CachedRemoteInputStream(child, getExecutionEnvironment()); |
684 |
} |
702 |
} |
685 |
|
703 |
|
Lines 696-702
Link Here
|
696 |
lock.unlock(); |
714 |
lock.unlock(); |
697 |
} |
715 |
} |
698 |
checkConnection(child, true); |
716 |
checkConnection(child, true); |
699 |
DirectoryStorage storage = getDirectoryStorage(); // do we need this? |
717 |
DirectoryStorage storage = getDirectoryStorage(child.getNameExt()); // do we need this? |
700 |
lock = RemoteFileSystem.getLock(child.getCache()).writeLock(); |
718 |
lock = RemoteFileSystem.getLock(child.getCache()).writeLock(); |
701 |
lock.lock(); |
719 |
lock.lock(); |
702 |
try { |
720 |
try { |
Lines 807-813
Link Here
|
807 |
|
825 |
|
808 |
private DirEntry getChildEntry(RemoteFileObjectBase child) { |
826 |
private DirEntry getChildEntry(RemoteFileObjectBase child) { |
809 |
try { |
827 |
try { |
810 |
DirectoryStorage directoryStorage = getDirectoryStorage(); |
828 |
DirectoryStorage directoryStorage = getDirectoryStorage(child.getNameExt()); |
811 |
if (directoryStorage != null) { |
829 |
if (directoryStorage != null) { |
812 |
DirEntry entry = directoryStorage.getEntry(child.getNameExt()); |
830 |
DirEntry entry = directoryStorage.getEntry(child.getNameExt()); |
813 |
if (entry != null) { |
831 |
if (entry != null) { |