Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
e
os
eDrive
Commits
56291c19
Commit
56291c19
authored
Nov 17, 2021
by
narinder Rana
Browse files
resolve ConcurrentModificationException
parent
c2e923f6
Pipeline
#146651
passed with stage
in 6 minutes and 44 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/foundation/e/drive/operations/UploadFileOperation.java
View file @
56291c19
...
...
@@ -23,6 +23,8 @@ import com.owncloud.android.lib.resources.users.GetRemoteUserInfoOperation;
import
com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
foundation.e.drive.database.DbHelper
;
import
foundation.e.drive.models.FileObserver
;
import
foundation.e.drive.models.SyncedFileState
;
...
...
@@ -140,7 +142,11 @@ public class UploadFileOperation extends RemoteOperation implements ComparableOp
//if upload is a success
if
(
uploadResult
.
isSuccess
()
){
FileObserverService
.
files
.
remove
(
file
);
try
{
FileObserverService
.
files
.
remove
(
file
);
}
catch
(
Exception
ex
){
ex
.
printStackTrace
();
}
Object
data
=
uploadResult
.
getSingleData
();
if
(
data
!=
null
){
...
...
app/src/main/java/foundation/e/drive/services/FileObserverService.java
View file @
56291c19
...
...
@@ -19,6 +19,7 @@ import android.util.Log;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
foundation.e.drive.receivers.ConnectivityReceiver
;
import
foundation.e.drive.utils.CommonUtils
;
...
...
@@ -31,7 +32,7 @@ public class FileObserverService extends Service {
private
final
static
String
TAG
=
FileObserverService
.
class
.
getSimpleName
();
RecursiveFileObserver
mFileObserver
=
null
;
private
int
observerFlag
=-
1
;
public
static
List
<
File
>
files
=
new
ArrayList
<>();
public
static
List
<
File
>
files
=
new
CopyOnWrite
ArrayList
<>();
private
boolean
remoteFileFlag
;
...
...
@@ -144,7 +145,10 @@ public class FileObserverService extends Service {
Intent
observersServiceIntent
=
new
Intent
(
getApplicationContext
(),
foundation
.
e
.
drive
.
services
.
ObserverService
.
class
);
Bundle
mBundle
=
new
Bundle
();
mBundle
.
putBoolean
(
"isFileObserverService"
,
true
);
mBundle
.
putByteArray
(
"fileObserverObject"
,
CommonUtils
.
convertToBytes
(
new
foundation
.
e
.
drive
.
models
.
FileObserver
(
files
)));
if
(
files
.
size
()!=
0
)
{
mBundle
.
putByteArray
(
"fileObserverObject"
,
CommonUtils
.
convertToBytes
(
new
foundation
.
e
.
drive
.
models
.
FileObserver
(
files
)));
}
observersServiceIntent
.
putExtras
(
mBundle
);
startService
(
observersServiceIntent
);
}
catch
(
Exception
exception
){
...
...
app/src/main/java/foundation/e/drive/services/ObserverService.java
View file @
56291c19
...
...
@@ -259,10 +259,9 @@ public class ObserverService extends Service implements OnRemoteOperationListene
return
;
}
}
else
{
if
(
isFileObserverService
&&
null
!=
fileObserverObject
)
{
Log
.
e
(
"TAG"
,
"ObserverService..isFileObserverService...."
+
isFileObserverService
);
if
(
isFileObserverService
&&
null
!=
fileObserverObject
)
{
Log
.
i
(
TAG
,
"calling observer service from event event with true and files list data"
);
// List<File> files = fileObserverObject.getFiles();
DbHelper
.
updateSyncedFolders
(
mSyncedFolders
,
this
);
//@ToDo: maybe do this when all contents will be synced.
...
...
@@ -275,6 +274,10 @@ public class ObserverService extends Service implements OnRemoteOperationListene
// handleLocalFiles(fileObserverObject.getFiles(), fileObserverObject.getSyncedFileStatesList());
}
else
{
Log
.
i
(
TAG
,
"calling observer service with false or files list data null "
);
if
(
null
!=
FileObserverService
.
files
){
FileObserverService
.
files
.
removeAll
(
FileObserverService
.
files
);
}
scanLocalFiles
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment