@@ -148,7 +148,6 @@ public class ReceiveExternalFilesActivity extends FileActivity
148148
149149 private SyncBroadcastReceiver mSyncBroadcastReceiver ;
150150 private ReceiveExternalFilesAdapter receiveExternalFilesAdapter ;
151- private boolean mSyncInProgress ;
152151
153152 private final static int REQUEST_CODE__SETUP_ACCOUNT = REQUEST_CODE__LAST_SHARED + 1 ;
154153
@@ -856,7 +855,6 @@ private void startSyncFolderOperation(OCFile folder) {
856855
857856 executorService .execute (() -> {
858857 long currentSyncTime = System .currentTimeMillis ();
859- mSyncInProgress = true ;
860858 final var optionalUser = getUser ();
861859 if (optionalUser .isEmpty ()) {
862860 DisplayUtils .showSnackMessage (this , R .string .user_information_retrieval_error );
@@ -1155,58 +1153,32 @@ public void onReceive(Context context, Intent intent) {
11551153 boolean sameAccount = getAccount () != null && accountName .equals (getAccount ().name )
11561154 && getStorageManager () != null ;
11571155
1158- if (sameAccount ) {
1159-
1160- if (FileSyncAdapter .EVENT_FULL_SYNC_START .equals (event )) {
1161- mSyncInProgress = true ;
1156+ if (sameAccount && !FileSyncAdapter .EVENT_FULL_SYNC_START .equals (event )) {
1157+ OCFile currentFile = (mFile == null ) ? null : getStorageManager ().getFileByPath (mFile .getRemotePath ());
1158+ OCFile currentDir = (getCurrentFolder () == null ) ? null : getStorageManager ().getFileByPath (getCurrentFolder ().getRemotePath ());
11621159
1160+ if (currentDir == null ) {
1161+ // current folder was removed from the server
1162+ DisplayUtils .showSnackMessage (getActivity (), R .string .sync_current_folder_was_removed , getCurrentFolder ().getFileName ());
1163+ browseToRoot ();
11631164 } else {
1164- OCFile currentFile = (mFile == null ) ? null :
1165- getStorageManager ().getFileByPath (mFile .getRemotePath ());
1166- OCFile currentDir = (getCurrentFolder () == null ) ? null :
1167- getStorageManager ().getFileByPath (getCurrentFolder ().getRemotePath ());
1168-
1169- if (currentDir == null ) {
1170- // current folder was removed from the server
1171- DisplayUtils .showSnackMessage (
1172- getActivity (),
1173- R .string .sync_current_folder_was_removed ,
1174- getCurrentFolder ().getFileName ()
1175- );
1176- browseToRoot ();
1177-
1178- } else {
1179- if (currentFile == null && !mFile .isFolder ()) {
1180- // currently selected file was removed in the server, and now we know it
1181- currentFile = currentDir ;
1182- }
1183-
1184- if (currentDir .getRemotePath ().equals (syncFolderRemotePath )) {
1185- populateDirectoryList (currentFile );
1186- }
1165+ if (currentFile == null && !mFile .isFolder ()) {
1166+ // currently selected file was removed in the server, and now we know it
1167+ currentFile = currentDir ;
11871168 }
11881169
1189- mSyncInProgress = !FileSyncAdapter .EVENT_FULL_SYNC_END .equals (event ) &&
1190- !RefreshFolderOperation .EVENT_SINGLE_FOLDER_SHARES_SYNCED .equals (event );
1191-
1192- if (RefreshFolderOperation .EVENT_SINGLE_FOLDER_CONTENTS_SYNCED .equals (event )
1193- /// TODO refactor and make common
1194- && syncResult != null && !syncResult .isSuccess ()) {
1195-
1196- if (syncResult .getCode () == ResultCode .UNAUTHORIZED ||
1197- (syncResult .isException () && syncResult .getException ()
1198- instanceof AuthenticatorException )) {
1199-
1200- requestCredentialsUpdate ();
1201-
1202- } else if (ResultCode .SSL_RECOVERABLE_PEER_UNVERIFIED == syncResult .getCode ()) {
1203-
1204- showUntrustedCertDialog (syncResult );
1205- }
1170+ if (currentDir .getRemotePath ().equals (syncFolderRemotePath )) {
1171+ populateDirectoryList (currentFile );
12061172 }
12071173 }
1208- Log_OC .d (TAG , "Setting progress visibility to " + mSyncInProgress );
12091174
1175+ if (RefreshFolderOperation .EVENT_SINGLE_FOLDER_CONTENTS_SYNCED .equals (event ) && syncResult != null && !syncResult .isSuccess ()) {
1176+ if (syncResult .getCode () == ResultCode .UNAUTHORIZED || (syncResult .isException () && syncResult .getException () instanceof AuthenticatorException )) {
1177+ requestCredentialsUpdate ();
1178+ } else if (ResultCode .SSL_RECOVERABLE_PEER_UNVERIFIED == syncResult .getCode ()) {
1179+ showUntrustedCertDialog (syncResult );
1180+ }
1181+ }
12101182 }
12111183 } catch (RuntimeException e ) {
12121184 // avoid app crashes after changing the serial id of RemoteOperationResult
0 commit comments