Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to delete PST file until jvm is terminated. #74

Open
ajaydarekar-ezest opened this issue Oct 25, 2018 · 1 comment
Open

Unable to delete PST file until jvm is terminated. #74

ajaydarekar-ezest opened this issue Oct 25, 2018 · 1 comment

Comments

@ajaydarekar-ezest
Copy link

ajaydarekar-ezest commented Oct 25, 2018

Please find code below. PSTFile object is not releasing reference of a file. I have to delete file once mails from PST files are read and stored in DB.

PSTFile pstFile = new PSTFile(tempFile);
processFolder(pstFile.getRootFolder(), emailCredentials, tags);
/FileUtils.cleanDirectory(dir);
dir.delete();
/
tempFile.delete();

Unable to delete tempFile from folder till jvm is started.

@schaitl
Copy link

schaitl commented Nov 30, 2018

I think you are supposed to close the PSTFile object like so:

final PSTFile pstFile = new PSTFile(tempFile);
try {
   processFolder(pstFile.getRootFolder(), emailCredentials, tags);
} finally {
   pstFile.close();
}
FileUtils.cleanDirectory(dir);

@rjohnsondev It actually would be great if future releases of libpst would let PSTFile implement java.lang.AutoCloseable to make this more obvious in an IDE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants