@@ -58,7 +58,7 @@ public abstract class Exporter {
5858 /**
5959 * Application folder on external storage
6060 */
61- public static final String BASE_FOLDER_PATH = Environment .getExternalStorageDirectory () + "/" + BuildConfig .APPLICATION_ID ;
61+ private static final String BASE_FOLDER_PATH = Environment .getExternalStorageDirectory () + "/" + BuildConfig .APPLICATION_ID ;
6262
6363 /**
6464 * Folder where exports like QIF and OFX will be saved for access by external programs
@@ -73,7 +73,7 @@ public abstract class Exporter {
7373 /**
7474 * Export options
7575 */
76- protected ExportParams mExportParams ;
76+ protected final ExportParams mExportParams ;
7777
7878 /**
7979 * Cache directory to which files will be first exported before moved to final destination.
@@ -82,7 +82,7 @@ public abstract class Exporter {
8282 * The files created here are only accessible within this application, and should be copied to SD card before they can be shared
8383 * </p>
8484 */
85- protected File mCacheDir ;
85+ private final File mCacheDir ;
8686
8787 private static final SimpleDateFormat EXPORT_FILENAME_DATE_FORMAT = new SimpleDateFormat ("yyyyMMdd_HHmmss" , Locale .US );
8888
@@ -96,13 +96,14 @@ public abstract class Exporter {
9696 * Adapter for retrieving accounts to export
9797 * Subclasses should close this object when they are done with exporting
9898 */
99- protected AccountsDbAdapter mAccountsDbAdapter ;
100- protected TransactionsDbAdapter mTransactionsDbAdapter ;
101- protected SplitsDbAdapter mSplitsDbAdapter ;
102- protected ScheduledActionDbAdapter mScheduledActionDbAdapter ;
103- protected PricesDbAdapter mPricesDbAdapter ;
104- protected CommoditiesDbAdapter mCommoditiesDbAdapter ;
105- protected Context mContext ;
99+ protected final AccountsDbAdapter mAccountsDbAdapter ;
100+ protected final TransactionsDbAdapter mTransactionsDbAdapter ;
101+ protected final SplitsDbAdapter mSplitsDbAdapter ;
102+ protected final ScheduledActionDbAdapter mScheduledActionDbAdapter ;
103+ protected final PricesDbAdapter mPricesDbAdapter ;
104+ protected final CommoditiesDbAdapter mCommoditiesDbAdapter ;
105+ protected final Context mContext ;
106+ private String mExportCacheFilePath ;
106107
107108 public Exporter (ExportParams params , SQLiteDatabase db ) {
108109 this .mExportParams = params ;
@@ -123,6 +124,7 @@ public Exporter(ExportParams params, SQLiteDatabase db) {
123124 mCommoditiesDbAdapter = new CommoditiesDbAdapter (db );
124125 }
125126
127+ mExportCacheFilePath = null ;
126128 mCacheDir = new File (mContext .getCacheDir (), params .getExportFormat ().name ());
127129 mCacheDir .mkdir ();
128130 purgeDirectory (mCacheDir );
@@ -184,10 +186,16 @@ private void purgeDirectory(File directory){
184186 * @return Absolute path to file
185187 */
186188 protected String getExportCacheFilePath (){
187- String cachePath = mCacheDir .getAbsolutePath ();
188- if (!cachePath .endsWith ("/" ))
189- cachePath += "/" ;
190- return cachePath + buildExportFilename (mExportParams .getExportFormat ());
189+ // The file name contains a timestamp, so ensure it doesn't change with multiple calls to
190+ // avoid issues like #448
191+ if (mExportCacheFilePath == null ) {
192+ String cachePath = mCacheDir .getAbsolutePath ();
193+ if (!cachePath .endsWith ("/" ))
194+ cachePath += "/" ;
195+ mExportCacheFilePath = cachePath + buildExportFilename (mExportParams .getExportFormat ());
196+ }
197+
198+ return mExportCacheFilePath ;
191199 }
192200
193201 /**
0 commit comments