[Esbox-commits] r2312 - branches/work_Ed/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences

eswartz at garage.maemo.org eswartz at garage.maemo.org
Thu Oct 15 19:03:44 EEST 2009


Author: eswartz
Date: 2009-10-15 19:03:33 +0300 (Thu, 15 Oct 2009)
New Revision: 2312

Modified:
   branches/work_Ed/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/ValidateMachineRunner.java
Log:
Handle validation case where EFS LocalFile system incorrectly caches files for too long

Modified: branches/work_Ed/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/ValidateMachineRunner.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/ValidateMachineRunner.java	2009-10-14 22:21:51 UTC (rev 2311)
+++ branches/work_Ed/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/ValidateMachineRunner.java	2009-10-15 16:03:33 UTC (rev 2312)
@@ -11,6 +11,7 @@
 
 package org.maemo.esbox.internal.api.maemosdk.ui.preferences;
 
+import java.io.File;
 import java.io.OutputStream;
 import java.lang.reflect.InvocationTargetException;
 import java.text.MessageFormat;
@@ -313,18 +314,26 @@
 			return false;
 		
 		// wait a little while for samba to notice, or else it looks like the file doesn't exist (:p !!!)
-		try {
-			Thread.sleep(2000);
-		} catch (InterruptedException e1) {
-		}
+		int sleepLeft = 1000 * 10;
+		do {
+			shareUserStore = share.isHostProvidedShare() 
+					? machine.getFileSystemAccess().getFileStore(shareUserFilePath)
+					: EFS.getLocalFileSystem().getStore(shareUserFilePath);
+					
+			fileExists = checkFileExists(new SubProgressMonitor(monitor, 1), shareUserStore);
+			if (!fileExists) {
+				try {
+					Thread.sleep(1000);
+					sleepLeft -= 1000;
+				} catch (InterruptedException e1) {
+				}
+			}
+		} while (!fileExists && sleepLeft > 0);
 		
-		shareUserStore = share.isHostProvidedShare() ? machine.getFileSystemAccess().getFileStore(shareUserFilePath)
-					: EFS.getLocalFileSystem().getStore(shareUserFilePath);
-		fileExists = checkFileExists(new SubProgressMonitor(monitor, 1), shareUserStore);
 		if (!fileExists) {
 			fail("Could not access {0} over SSH filesystem.\n\n"+
-					"If the share is mounted, then this file should be visible\n"
-					+"since we created it on the sharing machine\n"
+					"If the share is mounted, then this file should be visible "
+					+"since we created it on the sharing machine "
 					+"and this location is assumed to be shared at {1}. \n \n"+
 					"Make sure the host and target paths match, and that a different share "
 					+"is not already mounted there.",
@@ -355,6 +364,13 @@
 	private boolean checkFileExists(IProgressMonitor monitor,
 			IFileStore remoteStore) {
 		boolean fileExists = false;
+		
+		// HACK: localfile implementation can be buggy and have a long cache life
+		if (remoteStore.toURI().getScheme().equals("file")) {
+			File file = new File(remoteStore.toURI().getPath());
+			fileExists = file.exists();
+			return fileExists;
+		}
 		try {
 			IFileInfo info = remoteStore.fetchInfo(0, new SubProgressMonitor(monitor, 1));
 			fileExists = info.exists();



More information about the Esbox-commits mailing list