made UploadDbObject serializable

This commit is contained in:
Luke Owncloud 2014-11-05 15:49:03 +01:00
parent efe184939e
commit 1369ef8f28
9 changed files with 281 additions and 83 deletions

View file

@ -152,7 +152,7 @@
<service android:name=".services.OperationsService" />
<service android:name=".files.services.FileDownloader" />
<service android:name=".files.services.FileUploader" />
<service android:name=".files.services.FileUploadService" />
<service android:name=".media.MediaService" />
<activity android:name=".ui.activity.PinCodeActivity" />

View file

@ -17,8 +17,12 @@
*/
package com.owncloud.android.db;
import java.util.ArrayList;
import java.util.List;
import com.owncloud.android.MainApp;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.operations.UploadFileOperation;
import android.content.ContentValues;
import android.content.Context;
@ -39,10 +43,22 @@ public class UploadDbHandler {
private final String mDatabaseName;
private final int mDatabaseVersion = 4;
static private final String TAG = "UploadDbHandler";
static private final String TABLE_UPLOAD = "list_of_uploads";
public void recreateDb() {
mDB.beginTransaction();
try {
mHelper.onUpgrade(mDB, 0, mDatabaseVersion);
mDB.setTransactionSuccessful();
} finally {
mDB.endTransaction();
}
}
public enum UploadStatus {
UPLOAD_STATUS_UPLOAD_LATER(0), UPLOAD_STATUS_UPLOAD_FAILED(1);
UPLOAD_LATER(0), UPLOAD_FAILED(1), UPLOAD_IN_PROGRESS(2), UPLOAD_PAUSED(3), UPLOAD_SUCCEEDED(4);
private final int value;
private UploadStatus(int value) {
this.value = value;
@ -70,14 +86,17 @@ public class UploadDbHandler {
* @return false if an error occurred, else true.
*/
public boolean storeFile(String filepath, String account, String message) {
ContentValues cv = new ContentValues();
cv.put("path", filepath);
cv.put("account", account);
cv.put("attempt", UploadStatus.UPLOAD_STATUS_UPLOAD_LATER.getValue());
cv.put("message", message);
long result = mDB.insert(TABLE_UPLOAD, null, cv);
Log_OC.d(TABLE_UPLOAD, "putFileForLater returns with: " + result + " for file: " + filepath);
return result != -1;
///OBSOLETE
Log_OC.i(TAG, "obsolete method called");
return false;
// ContentValues cv = new ContentValues();
// cv.put("path", filepath);
// cv.put("account", account);
// cv.put("attempt", UploadStatus.UPLOAD_STATUS_UPLOAD_LATER.getValue());
// cv.put("message", message);
// long result = mDB.insert(TABLE_UPLOAD, null, cv);
// Log_OC.d(TABLE_UPLOAD, "putFileForLater returns with: " + result + " for file: " + filepath);
// return result != -1;
}
/**
@ -89,12 +108,15 @@ public class UploadDbHandler {
* @return 1 if file status was updated, else 0.
*/
public int updateFileState(String filepath, UploadStatus status, String message) {
ContentValues cv = new ContentValues();
cv.put("attempt", status.getValue());
cv.put("message", message);
int result = mDB.update(TABLE_UPLOAD, cv, "path=?", new String[] { filepath });
Log_OC.d(TABLE_UPLOAD, "updateFileState returns with: " + result + " for file: " + filepath);
return result;
///OBSOLETE
Log_OC.i(TAG, "obsolete method called");
return 0;
// ContentValues cv = new ContentValues();
// cv.put("attempt", status.getValue());
// cv.put("message", message);
// int result = mDB.update(TABLE_UPLOAD, cv, "path=?", new String[] { filepath });
// Log_OC.d(TABLE_UPLOAD, "updateFileState returns with: " + result + " for file: " + filepath);
// return result;
}
/**
@ -102,7 +124,10 @@ public class UploadDbHandler {
* @return
*/
public Cursor getAwaitingFiles() {
return mDB.query(TABLE_UPLOAD, null, "attempt=" + UploadStatus.UPLOAD_STATUS_UPLOAD_LATER, null, null, null, null);
//OBSOLETE
Log_OC.i(TAG, "obsolete method called");
return null;
// return mDB.query(TABLE_UPLOAD, null, "attempt=" + UploadStatus.UPLOAD_STATUS_UPLOAD_LATER, null, null, null, null);
}
//ununsed until now. uncomment if needed.
@ -121,9 +146,12 @@ public class UploadDbHandler {
* @return true when one or more pending files was removed
*/
public boolean removeFile(String localPath) {
long result = mDB.delete(TABLE_UPLOAD, "path = ?", new String[] { localPath });
Log_OC.d(TABLE_UPLOAD, "delete returns with: " + result + " for file: " + localPath);
return result != 0;
//OBSOLETE
Log_OC.i(TAG, "obsolete method called");
return false;
// long result = mDB.delete(TABLE_UPLOAD, "path = ?", new String[] { localPath });
// Log_OC.d(TABLE_UPLOAD, "delete returns with: " + result + " for file: " + localPath);
// return result != 0;
}
@ -134,35 +162,46 @@ public class UploadDbHandler {
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + TABLE_UPLOAD + " (" + " _id INTEGER PRIMARY KEY, " + " path TEXT,"
+ " account TEXT,attempt INTEGER,message TEXT,uploadObject TEXT);");
db.execSQL("CREATE TABLE " + TABLE_UPLOAD + " (" + " path TEXT PRIMARY KEY,"
+ " uploadObject TEXT);");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (oldVersion < 2) {
db.execSQL("ALTER TABLE " + TABLE_UPLOAD + " ADD COLUMN attempt INTEGER;");
}
if (oldVersion < 3) {
db.execSQL("ALTER TABLE " + TABLE_UPLOAD + " ADD COLUMN message TEXT;");
}
if (oldVersion < 4) {
db.execSQL("ALTER TABLE " + TABLE_UPLOAD + " ADD COLUMN uploadObject TEXT;");
if (newVersion == 4) {
db.execSQL("DROP TABLE IF EXISTS " + "instant_upload" + ";"); //drop old db (name)
db.execSQL("DROP TABLE IF EXISTS " + TABLE_UPLOAD + ";");
onCreate(db);
}
}
}
public boolean storeUpload(PersistentUploadObject uploadObject, String message) {
public boolean storeUpload(UploadDbObject uploadObject, String message) {
ContentValues cv = new ContentValues();
cv.put("path", uploadObject.getLocalPath());
cv.put("account", uploadObject.getAccountName());
cv.put("attempt", UploadStatus.UPLOAD_STATUS_UPLOAD_LATER.getValue());
cv.put("message", message);
cv.put("uploadObject", uploadObject.toString());
long result = mDB.insert(TABLE_UPLOAD, null, cv);
Log_OC.d(TABLE_UPLOAD, "putFileForLater returns with: " + result + " for file: " + uploadObject.getLocalPath());
Log_OC.d(TAG, "putFileForLater returns with: " + result + " for file: " + uploadObject.getLocalPath());
return result != -1;
}
public List<UploadDbObject> getAllStoredUploads() {
Cursor c = mDB.query(TABLE_UPLOAD, null, null, null, null, null, null);
List<UploadDbObject> list = new ArrayList<UploadDbObject>();
if (c.moveToFirst()) {
do {
String file_path = c.getString(c.getColumnIndex("path"));
String uploadObjectString = c.getString(c.getColumnIndex("uploadObject"));
UploadDbObject uploadObject = UploadDbObject.fromString(uploadObjectString);
if(uploadObject == null) {
Log_OC.e(TAG, "Could not deserialize UploadDbObject " + uploadObjectString);
} else {
list.add(uploadObject);
}
} while (c.moveToNext());
}
return list;
}
}

View file

@ -4,8 +4,18 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Base64;
import android.util.Log;
import com.owncloud.android.db.UploadDbHandler.UploadStatus;
import com.owncloud.android.files.services.FileUploadService.LocalBehaviour;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
/**
* Stores all information in order to start upload. PersistentUploadObject can
@ -14,7 +24,12 @@ import com.owncloud.android.files.services.FileUploadService.LocalBehaviour;
* @author LukeOwncloud
*
*/
public class PersistentUploadObject {
public class UploadDbObject implements Serializable{
/** Generated - should be refreshed every time the class changes!! */;
private static final long serialVersionUID = -2306246191385279924L;
private static final String TAG = "UploadDbObject";
/**
* Local path to file which is to be uploaded.
*/
@ -32,6 +47,34 @@ public class PersistentUploadObject {
* Local action for upload.
*/
LocalBehaviour localAction;
/**
* @return the uploadStatus
*/
public UploadStatus getUploadStatus() {
return uploadStatus;
}
/**
* @param uploadStatus the uploadStatus to set
*/
public void setUploadStatus(UploadStatus uploadStatus) {
this.uploadStatus = uploadStatus;
}
/**
* @return the lastResult
*/
public RemoteOperationResult getLastResult() {
return lastResult;
}
/**
* @param lastResult the lastResult to set
*/
public void setLastResult(RemoteOperationResult lastResult) {
this.lastResult = lastResult;
}
/**
* Overwrite destination file?
*/
@ -49,6 +92,16 @@ public class PersistentUploadObject {
*/
String accountName;
/**
* Status of upload (later, in_progress, ...).
*/
UploadStatus uploadStatus;
/**
* Result from last upload operation. Can be null.
*/
RemoteOperationResult lastResult;
/**
* @return the localPath
*/
@ -95,6 +148,7 @@ public class PersistentUploadObject {
* @return the localAction
*/
public LocalBehaviour getLocalAction() {
// return null;
return localAction;
}
@ -161,30 +215,71 @@ public class PersistentUploadObject {
this.accountName = accountName;
}
/**
* Returns a base64 encoded serialized string of this object.
*/
@Override
public String toString() {
// serialize the object
try {
ByteArrayOutputStream bo = new ByteArrayOutputStream();
ObjectOutputStream so = new ObjectOutputStream(bo);
so.writeObject(this);
so.flush();
return bo.toString();
String serializedObjectBase64 = Base64.encodeToString(bo.toByteArray(), Base64.DEFAULT);
so.close();
bo.close();
return serializedObjectBase64;
} catch (Exception e) {
System.out.println(e);
Log_OC.e(TAG, "Cannot serialize UploadDbObject with localPath:" + getLocalPath(), e);
}
//
// try {
// ByteArrayOutputStream bo = new ByteArrayOutputStream();
// ObjectOutputStream so = new ObjectOutputStream(bo);
// so.writeObject(this);
// so.flush();
// String base64 = Base64.encodeToString(bo.toString()
// .getBytes(), Base64.DEFAULT);
// return base64;
// } catch (Exception e) {
// System.out.println(e);
// }
return null;
}
public PersistentUploadObject fromString(String serializedObject) {
/**
* Accepts a base64 encoded serialized string of an {@link UploadDbObject}
* and instantiates and returns an according object.
*
* @param serializedObjectBase64
* @return
*/
static public UploadDbObject fromString(String serializedObjectBase64) {
// deserialize the object
try {
byte b[] = serializedObject.getBytes();
byte[] b = Base64.decode(serializedObjectBase64, Base64.DEFAULT);
ByteArrayInputStream bi = new ByteArrayInputStream(b);
ObjectInputStream si = new ObjectInputStream(bi);
return (PersistentUploadObject) si.readObject();
UploadDbObject obj = (UploadDbObject) si.readObject();
Log.e(TAG, "SUCCESS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
return obj;
} catch (Exception e) {
System.out.println(e);
Log_OC.e(TAG, "Cannot deserialize UploadDbObject " + serializedObjectBase64, e);
}
// try {
// byte b[] = Base64.decode(serializedObject, Base64.DEFAULT);
// ByteArrayInputStream bi = new ByteArrayInputStream(b);
// ObjectInputStream si = new ObjectInputStream(bi);
// return (UploadDbObject) si.readObject();
// } catch (Exception e) {
// Log_OC.e(TAG, "Cannot deserialize UploadDbObject " + serializedObject, e);
// }
return null;
}
}

View file

@ -101,7 +101,7 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
i.putExtra(FileUploadService.KEY_ACCOUNT, account);
i.putExtra(FileUploadService.KEY_LOCAL_FILE, file_path);
i.putExtra(FileUploadService.KEY_REMOTE_FILE, FileStorageUtils.getInstantUploadFilePath(context, file_name));
i.putExtra(FileUploadService.KEY_UPLOAD_TYPE, FileUploadService.UPLOAD_SINGLE_FILE);
i.putExtra(FileUploadService.KEY_UPLOAD_TYPE, FileUploadService.UploadSingleMulti.UPLOAD_SINGLE_FILE);
i.putExtra(FileUploadService.KEY_MIME_TYPE, mime_type);
i.putExtra(FileUploadService.KEY_CREATE_REMOTE_FOLDER, true);
i.putExtra(FileUploadService.KEY_WIFI_ONLY, instantPictureUploadViaWiFiOnly(context));
@ -143,7 +143,7 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
i.putExtra(FileUploadService.KEY_ACCOUNT, account);
i.putExtra(FileUploadService.KEY_LOCAL_FILE, file_path);
i.putExtra(FileUploadService.KEY_REMOTE_FILE, FileStorageUtils.getInstantUploadFilePath(context, file_name));
i.putExtra(FileUploadService.KEY_UPLOAD_TYPE, FileUploadService.UPLOAD_SINGLE_FILE);
i.putExtra(FileUploadService.KEY_UPLOAD_TYPE, FileUploadService.UploadSingleMulti.UPLOAD_SINGLE_FILE);
i.putExtra(FileUploadService.KEY_MIME_TYPE, mime_type);
i.putExtra(FileUploadService.KEY_CREATE_REMOTE_FOLDER, true);
i.putExtra(FileUploadService.KEY_WIFI_ONLY, instantVideoUploadViaWiFiOnly(context));

View file

@ -18,19 +18,23 @@
package com.owncloud.android.files.services;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.AbstractList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.accounts.AccountsException;
import android.app.NotificationManager;
import android.app.PendingIntent;
@ -48,6 +52,8 @@ import android.os.Looper;
import android.os.Message;
import android.os.Process;
import android.support.v4.app.NotificationCompat;
import android.util.Base64;
import android.util.Log;
import android.webkit.MimeTypeMap;
import com.owncloud.android.R;
@ -55,12 +61,12 @@ import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.authentication.AuthenticatorActivity;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.db.PersistentUploadObject;
import com.owncloud.android.db.UploadDbHandler;
import com.owncloud.android.db.UploadDbHandler.UploadStatus;
import com.owncloud.android.db.UploadDbObject;
import com.owncloud.android.lib.common.OwnCloudAccount;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
import com.owncloud.android.lib.common.accounts.AccountUtils.Constants;
import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
@ -120,23 +126,26 @@ public class FileUploadService extends Service {
this.value = value;
}
public int getValue() {
return value;
}
}
public enum UploadSingleMulti {
UPLOAD_SINGLE_FILE(0), UPLOAD_MULTIPLE_FILES(1);
private final int value;
private UploadSingleMulti(int value) {
this.value = value;
}
public int getValue() {
return value;
}
};
// public enum UploadSingleMulti {
// UPLOAD_SINGLE_FILE(0), UPLOAD_MULTIPLE_FILES(1);
// private final int value;
// private UploadSingleMulti(int value) {
// this.value = value;
// }
// public int getValue() {
// return value;
// }
// };
public static final int UPLOAD_SINGLE_FILE = 0;
public static final int UPLOAD_MULTIPLE_FILES = 1;
// public static final int UPLOAD_SINGLE_FILE = 0;
// public static final int UPLOAD_MULTIPLE_FILES = 1;
private static final String TAG = FileUploadService.class.getSimpleName();
@ -223,20 +232,28 @@ public class FileUploadService extends Service {
* New uploads are added calling to startService(), resulting in a call to
* this method. This ensures the service will keep on working although the
* caller activity goes away.
*
* First, onStartCommand() stores all information associated with the upload
* in a {@link UploadDbObject} which is stored persistently using
* {@link UploadDbHandler}. Then, {@link ServiceHandler} is invoked which
* performs the upload and updates the DB entry (upload success, failure,
* retry, ...)
*/
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
AbstractList<PersistentUploadObject> requestedUploads = new Vector<PersistentUploadObject>();
AbstractList<UploadDbObject> requestedUploads = new Vector<UploadDbObject>();
if (intent == null) {
// service was restarted by OS (after return START_STICKY and kill
// service) or connectivity change was detected. ==> check persistent upload
// list.
//
//TODO fill requestedUploads from DB
UploadDbHandler db = new UploadDbHandler(this.getBaseContext());
List<UploadDbObject> list = db.getAllStoredUploads();
requestedUploads.addAll(list);
} else {
int uploadType = intent.getIntExtra(KEY_UPLOAD_TYPE, -1);
if (uploadType == -1) {
UploadSingleMulti uploadType = (UploadSingleMulti) intent.getSerializableExtra(KEY_UPLOAD_TYPE);
if (uploadType == null) {
Log_OC.e(TAG, "Incorrect or no upload type provided");
return Service.START_NOT_STICKY;
}
@ -250,18 +267,16 @@ public class FileUploadService extends Service {
OCFile[] files = null;
// if KEY_FILE given, use it
if (intent.hasExtra(KEY_FILE)) {
if (uploadType == UPLOAD_SINGLE_FILE) {
if (uploadType == UploadSingleMulti.UPLOAD_SINGLE_FILE) {
files = new OCFile[] { intent.getParcelableExtra(KEY_FILE) };
} else {
// TODO will this casting work fine?
files = (OCFile[]) intent.getParcelableArrayExtra(KEY_FILE);
}
} else { // else use KEY_LOCAL_FILE, KEY_REMOTE_FILE, and
// KEY_MIME_TYPE
} else { // else use KEY_LOCAL_FILE and KEY_REMOTE_FILE
if (!intent.hasExtra(KEY_LOCAL_FILE) || !intent.hasExtra(KEY_REMOTE_FILE)
|| !(intent.hasExtra(KEY_MIME_TYPE))) {
if (!intent.hasExtra(KEY_LOCAL_FILE) || !intent.hasExtra(KEY_REMOTE_FILE)) {
Log_OC.e(TAG, "Not enough information provided in intent");
return Service.START_NOT_STICKY;
}
@ -269,7 +284,7 @@ public class FileUploadService extends Service {
String[] localPaths;
String[] remotePaths;
String[] mimeTypes;
if (uploadType == UPLOAD_SINGLE_FILE) {
if (uploadType == UploadSingleMulti.UPLOAD_SINGLE_FILE) {
localPaths = new String[] { intent.getStringExtra(KEY_LOCAL_FILE) };
remotePaths = new String[] { intent.getStringExtra(KEY_REMOTE_FILE) };
mimeTypes = new String[] { intent.getStringExtra(KEY_MIME_TYPE) };
@ -309,19 +324,63 @@ public class FileUploadService extends Service {
// failed.
UploadDbHandler db = new UploadDbHandler(this.getBaseContext());
for (int i = 0; i < files.length; i++) {
PersistentUploadObject uploadObject = new PersistentUploadObject();
UploadDbObject uploadObject = new UploadDbObject();
uploadObject.setRemotePath(files[i].getRemotePath());
uploadObject.setLocalPath(files[i].getStoragePath());
uploadObject.setMimeType(files[0].getMimetype());
uploadObject.setMimeType(files[i].getMimetype());
uploadObject.setAccountName(account.name);
uploadObject.setForceOverwrite(forceOverwrite);
uploadObject.setCreateRemoteFolder(isCreateRemoteFolder);
uploadObject.setLocalAction(localAction);
uploadObject.setUseWifiOnly(isUseWifiOnly);
uploadObject.setLastResult(new RemoteOperationResult(ResultCode.OK));
uploadObject.setLocalAction(LocalBehaviour.LOCAL_BEHAVIOUR_COPY);
uploadObject.setUploadStatus(UploadStatus.UPLOAD_LATER);
// String serializedObjectBase64 = "";
//
// // serialize the object
// try {
// ByteArrayOutputStream bo = new ByteArrayOutputStream();
// ObjectOutputStream so = new ObjectOutputStream(bo);
// so.writeObject(uploadObject);
// so.flush();
// serializedObjectBase64 = Base64.encodeToString(bo.toByteArray(), Base64.DEFAULT);
// so.close();
// bo.close();
// } catch (Exception e) {
// System.out.println(e);
// }
//
// // deserialize the object
// try {
// byte[] b = Base64.decode(serializedObjectBase64, Base64.DEFAULT);
// ByteArrayInputStream bi = new ByteArrayInputStream(b);
// ObjectInputStream si = new ObjectInputStream(bi);
// UploadDbObject obj = (UploadDbObject) si.readObject();
// Log.e(TAG, "SUCCESS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
// } catch (Exception e) {
// System.out.println(e);
// }
// String s = uploadObject.toString();
// UploadDbObject o = UploadDbObject.fromString(s);
// o = o;
db.storeUpload(uploadObject, "upload at " + new Date());
requestedUploads.add(uploadObject);
}
db.close();
return Service.START_NOT_STICKY;
// TODO check if would be clever to read entries from
// UploadDbHandler and add to requestedUploads at this point
// AccountManager aMgr = AccountManager.get(this);
// String version = aMgr.getUserData(account,
// Constants.KEY_OC_VERSION);
@ -335,7 +394,7 @@ public class FileUploadService extends Service {
// try {
// for (int i = 0; i < files.length; i++) {
// uploadKey = buildRemoteName(account, files[i].getRemotePath());
// newUpload = new UploadFileOperation(account, files[i], chunked,
// newUpload = new UploadFileOperation(account, files[i], chunked,
// forceOverwrite, localAction,
// getApplicationContext());
// if (isCreateRemoteFolder) {
@ -527,11 +586,12 @@ public class FileUploadService extends Service {
@Override
public void handleMessage(Message msg) {
@SuppressWarnings("unchecked")
AbstractList<String> requestedUploads = (AbstractList<String>) msg.obj;
AbstractList<UploadDbObject> requestedUploads = (AbstractList<UploadDbObject>) msg.obj;
if (msg.obj != null) {
Iterator<String> it = requestedUploads.iterator();
//TODO iterator returns UploadDbObject! Not a string.
Iterator<UploadDbObject> it = requestedUploads.iterator();
while (it.hasNext()) {
mService.uploadFile(it.next());
//mService.uploadFile(it.next());
}
}
mService.stopSelf(msg.arg1);
@ -834,7 +894,7 @@ public class FileUploadService extends Service {
// message =
// getString(R.string.failed_upload_quota_exceeded_text);
int updatedFiles = db.updateFileState(upload.getOriginalStoragePath(),
UploadDbHandler.UploadStatus.UPLOAD_STATUS_UPLOAD_FAILED, message);
UploadDbHandler.UploadStatus.UPLOAD_FAILED, message);
if (updatedFiles == 0) { // update failed
db.storeFile(upload.getOriginalStoragePath(), upload.getAccount().name, message);
}

View file

@ -212,7 +212,7 @@ public class SynchronizeFileOperation extends SyncOperation {
i.putExtra(FileUploadService.KEY_FILE, file);
/*i.putExtra(FileUploader.KEY_REMOTE_FILE, mRemotePath); // doing this we would lose the value of keepInSync in the road, and maybe it's not updated in the database when the FileUploader service gets it!
i.putExtra(FileUploader.KEY_LOCAL_FILE, localFile.getStoragePath());*/
i.putExtra(FileUploadService.KEY_UPLOAD_TYPE, FileUploadService.UPLOAD_SINGLE_FILE);
i.putExtra(FileUploadService.KEY_UPLOAD_TYPE, FileUploadService.UploadSingleMulti.UPLOAD_SINGLE_FILE);
i.putExtra(FileUploadService.KEY_FORCE_OVERWRITE, true);
mContext.startService(i);
mTransferWasRequested = true;

View file

@ -20,6 +20,7 @@ package com.owncloud.android.ui.activity;
import com.actionbarsherlock.app.ActionBar;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.db.UploadDbObject;
import com.owncloud.android.files.services.FileUploadService;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.ui.dialog.ConflictsResolveDialog;
@ -68,7 +69,7 @@ public class ConflictsResolveActivity extends FileActivity implements OnConflict
}
i.putExtra(FileUploadService.KEY_ACCOUNT, getAccount());
i.putExtra(FileUploadService.KEY_FILE, getFile());
i.putExtra(FileUploadService.KEY_UPLOAD_TYPE, FileUploadService.UPLOAD_SINGLE_FILE);
i.putExtra(FileUploadService.KEY_UPLOAD_TYPE, FileUploadService.UploadSingleMulti.UPLOAD_SINGLE_FILE);
startService(i);
finish();

View file

@ -64,6 +64,7 @@ import com.owncloud.android.BuildConfig;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.db.UploadDbObject;
import com.owncloud.android.files.services.FileDownloader;
import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
import com.owncloud.android.files.services.FileUploadService;
@ -638,7 +639,7 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
i.putExtra(FileUploadService.KEY_ACCOUNT, getAccount());
i.putExtra(FileUploadService.KEY_LOCAL_FILE, filePaths);
i.putExtra(FileUploadService.KEY_REMOTE_FILE, remotePaths);
i.putExtra(FileUploadService.KEY_UPLOAD_TYPE, FileUploadService.UPLOAD_MULTIPLE_FILES);
i.putExtra(FileUploadService.KEY_UPLOAD_TYPE, FileUploadService.UploadSingleMulti.UPLOAD_MULTIPLE_FILES);
if (resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)
i.putExtra(FileUploadService.KEY_LOCAL_BEHAVIOUR, FileUploadService.LocalBehaviour.LOCAL_BEHAVIOUR_MOVE);
startService(i);
@ -691,11 +692,13 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
i.putExtra(FileUploadService.KEY_LOCAL_FILE, filepath);
i.putExtra(FileUploadService.KEY_REMOTE_FILE, remotepath);
i.putExtra(FileUploadService.KEY_UPLOAD_TYPE, FileUploadService.UPLOAD_SINGLE_FILE);
i.putExtra(FileUploadService.KEY_UPLOAD_TYPE, FileUploadService.UploadSingleMulti.UPLOAD_SINGLE_FILE);
if (resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE) {
i.putExtra(FileUploadService.KEY_LOCAL_BEHAVIOUR, FileUploadService.LocalBehaviour.LOCAL_BEHAVIOUR_MOVE);
}
startService(i);
if(startService(i) == null) {
Log_OC.e(TAG, "FileUploadService could not be started");
}
}
/**

View file

@ -403,7 +403,7 @@ public class Uploader extends ListActivity implements OnItemClickListener, andro
}
Intent intent = new Intent(getApplicationContext(), FileUploadService.class);
intent.putExtra(FileUploadService.KEY_UPLOAD_TYPE, FileUploadService.UPLOAD_MULTIPLE_FILES);
intent.putExtra(FileUploadService.KEY_UPLOAD_TYPE, FileUploadService.UploadSingleMulti.UPLOAD_MULTIPLE_FILES);
intent.putExtra(FileUploadService.KEY_LOCAL_FILE, local.toArray(new String[local.size()]));
intent.putExtra(FileUploadService.KEY_REMOTE_FILE, remote.toArray(new String[remote.size()]));
intent.putExtra(FileUploadService.KEY_ACCOUNT, mAccount);