@@ -95,29 +95,31 @@ private File getDataFile() {
9595 }
9696 }
9797 } else {
98- try {
99- String noBackUpFilePath =
100- firebaseApp .getApplicationContext ().getNoBackupFilesDir ().getCanonicalPath ();
101- if (dataFile .getCanonicalPath ().startsWith (noBackUpFilePath )) {
102- return dataFile ;
103- } else {
104- // Move the file to the no back up directory.
105- File dataFileNonBackup =
106- new File (
107- firebaseApp .getApplicationContext ().getNoBackupFilesDir (),
108- SETTINGS_FILE_NAME_PREFIX + "." + firebaseApp .getPersistenceKey () + ".json" );
109-
110- if (!dataFile .renameTo (dataFileNonBackup )) {
111- Log .e (
112- TAG ,
113- "Unable to move the file from back up to non back up directory" ,
114- new IOException ("Unable to move the file from back up to non back up directory" ));
98+ synchronized (this ) {
99+ try {
100+ String noBackUpFilePath =
101+ firebaseApp .getApplicationContext ().getNoBackupFilesDir ().getCanonicalPath ();
102+ if (dataFile .getCanonicalPath ().startsWith (noBackUpFilePath )) {
103+ return dataFile ;
115104 } else {
116- dataFile = dataFileNonBackup ;
105+ // Move the file to the no back up directory.
106+ File dataFileNonBackup =
107+ new File (
108+ firebaseApp .getApplicationContext ().getNoBackupFilesDir (),
109+ SETTINGS_FILE_NAME_PREFIX + "." + firebaseApp .getPersistenceKey () + ".json" );
110+
111+ if (!dataFile .renameTo (dataFileNonBackup )) {
112+ Log .e (
113+ TAG ,
114+ "Unable to move the file from back up to non back up directory" ,
115+ new IOException ("Unable to move the file from back up to non back up directory" ));
116+ } else {
117+ dataFile = dataFileNonBackup ;
118+ }
117119 }
120+ } catch (IOException e ) {
121+ Log .e (TAG , "Error copying data file to non back up directory" , e );
118122 }
119- } catch (IOException e ) {
120- Log .e (TAG , "Error copying data file to non back up directory" , e );
121123 }
122124 }
123125
0 commit comments