summaryrefslogtreecommitdiff
path: root/org.tizen.common.sdblib
diff options
context:
space:
mode:
authorshingil.kang <shingil.kang@samsung.com>2013-06-21 15:46:52 +0900
committershingil.kang <shingil.kang@samsung.com>2013-06-24 04:48:16 +0900
commitb309e2d2a3d15361fe8f830100b4100dcfcb31b7 (patch)
treed289e451d0e48587404c3919dab21a70c2a537d1 /org.tizen.common.sdblib
parent66550fc6d58d8bd50fb2f6522c9e541952439283 (diff)
downloadcommon-eplugin-b309e2d2a3d15361fe8f830100b4100dcfcb31b7.tar.gz
common-eplugin-b309e2d2a3d15361fe8f830100b4100dcfcb31b7.tar.bz2
common-eplugin-b309e2d2a3d15361fe8f830100b4100dcfcb31b7.zip
[Title] fix a bug where transfer dialog of connection explorer show wrong file size when dropping (pushing) files
[Desc.] [Issue] Change-Id: Ib15d56d16d41b70f18dd59e7ed2d152c0916a512
Diffstat (limited to 'org.tizen.common.sdblib')
-rw-r--r--org.tizen.common.sdblib/src/org/tizen/sdblib/service/SyncService.java96
1 files changed, 63 insertions, 33 deletions
diff --git a/org.tizen.common.sdblib/src/org/tizen/sdblib/service/SyncService.java b/org.tizen.common.sdblib/src/org/tizen/sdblib/service/SyncService.java
index 86af582f7..493401949 100644
--- a/org.tizen.common.sdblib/src/org/tizen/sdblib/service/SyncService.java
+++ b/org.tizen.common.sdblib/src/org/tizen/sdblib/service/SyncService.java
@@ -434,7 +434,7 @@ implements Closeable
* @param time out value while push the files
* @return a {@link SyncResult} object with a code and an optional message.
*
- * @see #doPush(InputStream, FileEntry, ISyncProgressMonitor, int)
+ * @see #push(File[], FileEntry, ISyncProgressMonitor, int)
*/
public
SyncResult
@@ -455,17 +455,56 @@ implements Closeable
monitor.startSubTask(MESSAGE_SIZECHECKING);
+ SyncResult result;
+
try {
// get the total count of the bytes to transfer
long total = getTotalLocalFileSizeLong( locals, monitor );
monitor.startSubTask( MESSAGE_PUSH_FILES );
monitor.stop();
+ //start the monitor
monitor.start( total );
+ result = doPush(locals, remote, monitor, timeOut);
+ }
+ catch ( final InterruptedException e )
+ {
+ return new SyncResult( RESULT_CANCELED );
+ }
+ finally
+ {
+ monitor.stop();
+ }
+
+ return result;
+ }
+
+ /**
+ * Push several files.
+ * @param locals An array of loca files to push
+ * @param remote the remote {@link FileEntry} representing a directory.
+ * @param monitor The progress monitor. Cannot be null.
+ * @param time out value while push the files
+ * @return a {@link SyncResult} object with a code and an optional message.
+ *
+ * @see #doPush(File[], FileEntry, ISyncProgressMonitor, int)
+ */
+ public
+ SyncResult
+ doPush(
+ final File[] locals,
+ final FileEntry remote,
+ ISyncProgressMonitor monitor,
+ final int timeOut
+ )
+ {
+ monitor = nvl( monitor, NullSyncProgressMonitor.getInstance() );
+
+ try {
+
final String remotePath = remote.getFullPath();
-
-
+
for ( final File f : locals )
{
// check if we're canceled
@@ -475,7 +514,7 @@ implements Closeable
if ( !f.exists() )
{
- continue;
+ continue;
}
final String path = addTailingPath( remotePath, f.getName() );
@@ -484,27 +523,27 @@ implements Closeable
monitor.startSubTask( String.format("%s\t%s", f.getAbsolutePath(), path ) );
if ( f.isDirectory() )
{
- SyncResult result = push( f.listFiles(), remoteFile, monitor, timeOut);
-
- if (result.getCode() != RESULT_OK)
- {
- return result;
- }
+ SyncResult result = doPush( f.listFiles(), remoteFile, monitor, timeOut);
+
+ if (result.getCode() != RESULT_OK)
+ {
+ return result;
+ }
}
- else if (f.isFile() )
+ else if ( f.isFile() )
{
- FileInputStream fileIn = new FileInputStream( f );
- try
- {
- SyncResult result = doPush( fileIn, remoteFile, monitor, timeOut);
- if (result.getCode() != RESULT_OK) {
- return result;
- }
- }
- finally
- {
- tryClose( fileIn );
- }
+ FileInputStream fileIn = new FileInputStream( f );
+ try
+ {
+ SyncResult result = doPush( fileIn, remoteFile, monitor, timeOut);
+ if (result.getCode() != RESULT_OK) {
+ return result;
+ }
+ }
+ finally
+ {
+ tryClose( fileIn );
+ }
}
}
@@ -512,17 +551,8 @@ implements Closeable
} catch ( final IOException e )
{
- return new SyncResult( RESULT_FILE_READ_ERROR );
- }
- catch ( final InterruptedException e )
- {
- return new SyncResult(RESULT_CANCELED);
+ return new SyncResult( RESULT_FILE_READ_ERROR, e );
}
- finally
- {
- monitor.stop();
- }
-
}
/**