Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/analysis/findbugs-results.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
383
384
175 changes: 148 additions & 27 deletions src/main/java/com/owncloud/android/datamodel/SyncedFolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,37 @@ public class SyncedFolder implements Serializable, Cloneable {
public static final long EMPTY_ENABLED_TIMESTAMP_MS = -1;
private static final long serialVersionUID = -793476118299906429L;

@Getter @Setter private long id;
@Getter @Setter private String localPath;
@Getter @Setter private String remotePath;
@Getter @Setter private boolean wifiOnly;
@Getter @Setter private boolean chargingOnly;
@Getter @Setter private boolean existing;
@Getter @Setter private boolean subfolderByDate;
@Getter @Setter private String account;
@Getter @Setter private int uploadAction;
@Getter private boolean enabled;
@Getter private long enabledTimestampMs;
@Getter @Setter private MediaFolderType type;
@Getter @Setter private boolean hidden;
private long id;
private String localPath;
private String remotePath;
private boolean wifiOnly;
private boolean chargingOnly;
private boolean existing;
private boolean subfolderByDate;
private String account;
private int uploadAction;
private int nameCollisionPolicy;
private boolean enabled;
private long enabledTimestampMs;
private MediaFolderType type;
private boolean hidden;

/**
* constructor for new, to be persisted entity.
*
* @param localPath local path
* @param remotePath remote path
* @param wifiOnly upload on wifi only flag
* @param chargingOnly upload on charging only
* @param existing upload existing files
* @param subfolderByDate create sub-folders by date (month)
* @param account the account owning the synced folder
* @param uploadAction the action to be done after the upload
* @param enabled flag if synced folder config is active
* @param timestampMs the current timestamp in milliseconds
* @param type the type of the folder
* @param hidden hide item flag
* @param localPath local path
* @param remotePath remote path
* @param wifiOnly upload on wifi only flag
* @param chargingOnly upload on charging only
* @param existing upload existing files
* @param subfolderByDate create sub-folders by date (month)
* @param account the account owning the synced folder
* @param uploadAction the action to be done after the upload
* @param nameCollisionPolicy the behaviour to follow if detecting a collision
* @param enabled flag if synced folder config is active
* @param timestampMs the current timestamp in milliseconds
* @param type the type of the folder
* @param hidden hide item flag
*/
public SyncedFolder(String localPath,
String remotePath,
Expand All @@ -72,12 +74,25 @@ public SyncedFolder(String localPath,
boolean subfolderByDate,
String account,
int uploadAction,
int nameCollisionPolicy,
boolean enabled,
long timestampMs,
MediaFolderType type,
boolean hidden) {
this(UNPERSISTED_ID, localPath, remotePath, wifiOnly, chargingOnly, existing, subfolderByDate, account,
uploadAction, enabled, timestampMs, type, hidden);
this(UNPERSISTED_ID,
localPath,
remotePath,
wifiOnly,
chargingOnly,
existing,
subfolderByDate,
account,
uploadAction,
nameCollisionPolicy,
enabled,
timestampMs,
type,
hidden);
}

/**
Expand All @@ -94,6 +109,7 @@ protected SyncedFolder(long id,
boolean subfolderByDate,
String account,
int uploadAction,
int nameCollisionPolicy,
boolean enabled,
long timestampMs,
MediaFolderType type,
Expand All @@ -107,6 +123,7 @@ protected SyncedFolder(long id,
this.subfolderByDate = subfolderByDate;
this.account = account;
this.uploadAction = uploadAction;
this.nameCollisionPolicy = nameCollisionPolicy;
this.setEnabled(enabled, timestampMs);
this.type = type;
this.hidden = hidden;
Expand All @@ -127,4 +144,108 @@ public Object clone() {
return null;
}
}

public long getId() {
return this.id;
}

public String getLocalPath() {
return this.localPath;
}

public String getRemotePath() {
return this.remotePath;
}

public boolean isWifiOnly() {
return this.wifiOnly;
}

public boolean isChargingOnly() {
return this.chargingOnly;
}

public boolean isExisting() {
return this.existing;
}

public boolean isSubfolderByDate() {
return this.subfolderByDate;
}

public String getAccount() {
return this.account;
}

public int getUploadAction() {
return this.uploadAction;
}

public int getNameCollisionPolicy() {
return this.nameCollisionPolicy;
}

public boolean isEnabled() {
return this.enabled;
}

public long getEnabledTimestampMs() {
return this.enabledTimestampMs;
}

public MediaFolderType getType() {
return this.type;
}

public boolean isHidden() {
return this.hidden;
}

public void setId(long id) {
this.id = id;
}

public void setLocalPath(String localPath) {
this.localPath = localPath;
}

public void setRemotePath(String remotePath) {
this.remotePath = remotePath;
}

public void setWifiOnly(boolean wifiOnly) {
this.wifiOnly = wifiOnly;
}

public void setChargingOnly(boolean chargingOnly) {
this.chargingOnly = chargingOnly;
}

public void setExisting(boolean existing) {
this.existing = existing;
}

public void setSubfolderByDate(boolean subfolderByDate) {
this.subfolderByDate = subfolderByDate;
}

public void setAccount(String account) {
this.account = account;
}

public void setUploadAction(int uploadAction) {
this.uploadAction = uploadAction;
}

public void setNameCollisionPolicy(int nameCollisionPolicy) {
this.nameCollisionPolicy = nameCollisionPolicy;
}

public void setType(MediaFolderType type) {
this.type = type;
}

public void setHidden(boolean hidden) {
this.hidden = hidden;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,28 @@ public SyncedFolderDisplayItem(long id,
boolean subfolderByDate,
String account,
int uploadAction,
int nameCollisionPolicy,
boolean enabled,
long timestampMs,
List<String> filePaths,
String folderName,
long numberOfFiles,
MediaFolderType type,
boolean hidden) {
super(id, localPath, remotePath, wifiOnly, chargingOnly, existing, subfolderByDate, account, uploadAction,
enabled, timestampMs, type, hidden);
super(id,
localPath,
remotePath,
wifiOnly,
chargingOnly,
existing,
subfolderByDate,
account,
uploadAction,
nameCollisionPolicy,
enabled,
timestampMs,
type,
hidden);
this.filePaths = filePaths;
this.folderName = folderName;
this.numberOfFiles = numberOfFiles;
Expand All @@ -88,11 +101,26 @@ public SyncedFolderDisplayItem(long id,
boolean subfolderByDate,
String account,
int uploadAction,
int nameCollisionPolicy,
boolean enabled,
long timestampMs,
String folderName, MediaFolderType type, boolean hidden) {
super(id, localPath, remotePath, wifiOnly, chargingOnly, existing, subfolderByDate, account, uploadAction,
enabled, timestampMs, type, hidden);
String folderName,
MediaFolderType type,
boolean hidden) {
super(id,
localPath,
remotePath,
wifiOnly,
chargingOnly,
existing,
subfolderByDate,
account,
uploadAction,
nameCollisionPolicy,
enabled,
timestampMs,
type,
hidden);
this.folderName = folderName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ private SyncedFolder createSyncedFolderFromCursor(Cursor cursor) {
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT));
int uploadAction = cursor.getInt(cursor.getColumnIndex(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_UPLOAD_ACTION));
int nameCollisionPolicy = cursor.getInt(cursor.getColumnIndex(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_NAME_COLLISION_POLICY));
boolean enabled = cursor.getInt(cursor.getColumnIndex(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED)) == 1;
long enabledTimestampMs = cursor.getLong(cursor.getColumnIndex(
Expand All @@ -359,9 +361,20 @@ private SyncedFolder createSyncedFolderFromCursor(Cursor cursor) {
boolean hidden = cursor.getInt(cursor.getColumnIndex(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_HIDDEN)) == 1;

syncedFolder = new SyncedFolder(id, localPath, remotePath, wifiOnly, chargingOnly, existing,
subfolderByDate, accountName, uploadAction, enabled, enabledTimestampMs,
type, hidden);
syncedFolder = new SyncedFolder(id,
localPath,
remotePath,
wifiOnly,
chargingOnly,
existing,
subfolderByDate,
accountName,
uploadAction,
nameCollisionPolicy,
enabled,
enabledTimestampMs,
type,
hidden);
}
return syncedFolder;
}
Expand All @@ -385,6 +398,8 @@ private ContentValues createContentValuesFromSyncedFolder(SyncedFolder syncedFol
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE, syncedFolder.isSubfolderByDate());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT, syncedFolder.getAccount());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_UPLOAD_ACTION, syncedFolder.getUploadAction());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_NAME_COLLISION_POLICY,
syncedFolder.getNameCollisionPolicy());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_TYPE, syncedFolder.getType().getId());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_HIDDEN, syncedFolder.isHidden());

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/owncloud/android/db/ProviderMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
public class ProviderMeta {
public static final String DB_NAME = "filelist";
public static final int DB_VERSION = 54;
public static final int DB_VERSION = 55;

private ProviderMeta() {
// No instance
Expand Down Expand Up @@ -230,6 +230,7 @@ static public class ProviderTableMeta implements BaseColumns {
public static final String SYNCED_FOLDER_SUBFOLDER_BY_DATE = "subfolder_by_date";
public static final String SYNCED_FOLDER_ACCOUNT = "account";
public static final String SYNCED_FOLDER_UPLOAD_ACTION = "upload_option";
public static final String SYNCED_FOLDER_NAME_COLLISION_POLICY = "name_collision_policy";
public static final String SYNCED_FOLDER_HIDDEN = "hidden";

// Columns of external links table
Expand Down
22 changes: 12 additions & 10 deletions src/main/java/com/owncloud/android/jobs/FilesSyncJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,26 +165,25 @@ private void syncFolder(
SimpleDateFormat sFormatter,
SyncedFolder syncedFolder
) {
String remotePath;
boolean subfolderByDate;
Integer uploadAction;
boolean needsCharging;
boolean needsWifi;
File file;
ArbitraryDataProvider arbitraryDataProvider;
String accountName = syncedFolder.getAccount();
Optional<User> optionalUser = userAccountManager.getUser(accountName);
if (!optionalUser.isPresent()) {
return;
}
User user = optionalUser.get();

ArbitraryDataProvider arbitraryDataProvider = null;
if (lightVersion) {
arbitraryDataProvider = new ArbitraryDataProvider(context.getContentResolver());
} else {
arbitraryDataProvider = null;
}

String remotePath;
boolean subfolderByDate;
Integer uploadAction;
FileUploader.NameCollisionPolicy nameCollisionPolicy;
boolean needsCharging;
boolean needsWifi;
File file;
for (String path : filesystemDataProvider.getFilesForUpload(syncedFolder.getLocalPath(),
Long.toString(syncedFolder.getId()))) {
file = new File(path);
Expand All @@ -197,12 +196,15 @@ private void syncFolder(
SettingsActivity.SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI);
String uploadActionString = resources.getString(R.string.syncedFolder_light_upload_behaviour);
uploadAction = getUploadAction(uploadActionString);
nameCollisionPolicy = FileUploader.NameCollisionPolicy.ASK_USER;
subfolderByDate = resources.getBoolean(R.bool.syncedFolder_light_use_subfolders);
remotePath = resources.getString(R.string.syncedFolder_remote_folder);
} else {
needsCharging = syncedFolder.isChargingOnly();
needsWifi = syncedFolder.isWifiOnly();
uploadAction = syncedFolder.getUploadAction();
nameCollisionPolicy = FileUploader.NameCollisionPolicy.deserialize(
syncedFolder.getNameCollisionPolicy());
subfolderByDate = syncedFolder.isSubfolderByDate();
remotePath = syncedFolder.getRemotePath();
}
Expand All @@ -224,7 +226,7 @@ private void syncFolder(
UploadFileOperation.CREATED_AS_INSTANT_PICTURE,
needsWifi,
needsCharging,
FileUploader.NameCollisionPolicy.ASK_USER
nameCollisionPolicy
);

filesystemDataProvider.updateFilesystemFileAsSentForUpload(path,
Expand Down
Loading