-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from markus-s24/cleanup-entity-temp-files
Take care that BulkServiceManager deletes its temp files
- Loading branch information
Showing
4 changed files
with
103 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 6 additions & 3 deletions
9
src/main/java/com/microsoft/bingads/v10/internal/bulk/BulkFileReaderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
package com.microsoft.bingads.v10.internal.bulk; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import com.microsoft.bingads.v10.bulk.BulkFileReader; | ||
import com.microsoft.bingads.v10.bulk.DownloadFileType; | ||
import com.microsoft.bingads.v10.bulk.ResultFileType; | ||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
public interface BulkFileReaderFactory { | ||
|
||
BulkFileReader createBulkFileReader(File localFile, ResultFileType fileType, DownloadFileType downloadFileType) throws IOException; | ||
BulkFileReader createBulkFileReader( | ||
File localFile, ResultFileType fileType, DownloadFileType downloadFileType, boolean deleteFileOnClose) | ||
throws IOException; | ||
|
||
} |
25 changes: 18 additions & 7 deletions
25
src/main/java/com/microsoft/bingads/v10/internal/bulk/CSVBulkFileReaderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,28 @@ | ||
package com.microsoft.bingads.v10.internal.bulk; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import com.microsoft.bingads.v10.bulk.BulkFileReader; | ||
import com.microsoft.bingads.v10.bulk.DownloadFileType; | ||
import com.microsoft.bingads.v10.bulk.ResultFileType; | ||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
public class CSVBulkFileReaderFactory implements BulkFileReaderFactory { | ||
|
||
@Override | ||
public BulkFileReader createBulkFileReader(File localFile, | ||
ResultFileType resultType, DownloadFileType downloadFileType) throws IOException { | ||
return new BulkFileReader(localFile, resultType, downloadFileType); | ||
public BulkFileReader createBulkFileReader( | ||
final File localFile, ResultFileType resultType, DownloadFileType downloadFileType, final boolean deleteFileOnClose) | ||
throws IOException { | ||
return new BulkFileReader(localFile, resultType, downloadFileType) { | ||
@Override | ||
public void close() throws IOException { | ||
try { | ||
super.close(); | ||
} finally { | ||
if (deleteFileOnClose) { | ||
localFile.delete(); | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters