[Esbox-commits] r852 - trunk/device/org.maemo.esbox.device.launch.rse/src/org/maemo/esbox/device/launch/rse
lwang at garage.maemo.org
lwang at garage.maemo.org
Thu Oct 9 19:56:11 EEST 2008
Author: lwang
Date: 2008-10-09 19:56:10 +0300 (Thu, 09 Oct 2008)
New Revision: 852
Modified:
trunk/device/org.maemo.esbox.device.launch.rse/src/org/maemo/esbox/device/launch/rse/RSELaunchProtocol.java
Log:
Ask RSE to create non-existent folders before downloading.
Modified: trunk/device/org.maemo.esbox.device.launch.rse/src/org/maemo/esbox/device/launch/rse/RSELaunchProtocol.java
===================================================================
--- trunk/device/org.maemo.esbox.device.launch.rse/src/org/maemo/esbox/device/launch/rse/RSELaunchProtocol.java 2008-10-09 15:06:08 UTC (rev 851)
+++ trunk/device/org.maemo.esbox.device.launch.rse/src/org/maemo/esbox/device/launch/rse/RSELaunchProtocol.java 2008-10-09 16:56:10 UTC (rev 852)
@@ -150,25 +150,47 @@
for (Map.Entry<IPath, List<IPath>> p : targetPathToHostFiles.entrySet())
total += p.getValue().size();
- monitor.beginTask("", total*2 + 1);
+ monitor.beginTask("", total*2 + targetPathToHostFiles.entrySet().size() + 1);
+ IProgressMonitor subMon = null;
+
for (Map.Entry<IPath, List<IPath>> pathEntry : targetPathToHostFiles.entrySet()) {
List<IPath> hostFilePaths = pathEntry.getValue();
+ // Make sure the target path has trailing separator.
String targetPath = pathEntry.getKey().addTrailingSeparator().toPortableString();
+ // Make sure the "targetPath" exists by creating it.
+ //
+ String msg = MessageFormat.format("Creating folder ''{0}'' on device ", targetPath);
+ monitor.subTask(msg);
+ subMon = new SubProgressMonitor(monitor, 1);
+ subMon.beginTask("", 100);
+ IRemoteFile remoteFolder;
+ try {
+ remoteFolder = fss.getRemoteFileObject(targetPath, subMon);
+ subMon.worked(50);
+
+ if (! remoteFolder.exists())
+ fss.createFolders(remoteFolder, subMon);
+
+ subMon.done();
+ } catch (SystemMessageException e1) {
+ return new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), msg + " failed", e1);
+ }
+
+ // Now download files.
+ //
for (IPath hostFilePath : hostFilePaths) {
String hostFile = hostFilePath.toPortableString();
- String msg = MessageFormat.format("Download ''{0}'' to ''{1}''", hostFile, targetPath);
- IProgressMonitor subMon = null;
- if (monitor != null) {
- monitor.subTask(msg);
- subMon = new SubProgressMonitor(monitor, 2);
- subMon.beginTask("", 100);
- }
+ msg = MessageFormat.format("Download ''{0}'' to ''{1}''", hostFile, targetPath);
+ monitor.subTask(msg);
+ subMon = new SubProgressMonitor(monitor, 2);
+ subMon.beginTask("", 100);
+
// TODO: check timestamps
try {
@@ -190,7 +212,7 @@
permissions.setPermission(IHostFilePermissions.PERM_USER_EXECUTE, true);
fps.setFilePermissions(rfile.getHostFile(), permissions, subMon);
}
- subMon.worked(25);
+ subMon.done();
}
} catch (SystemMessageException e) {
return new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), msg + " failed", e);
More information about the Esbox-commits
mailing list