Skip to content

Commit

Permalink
fix: use random UUID for external resources
Browse files Browse the repository at this point in the history
  • Loading branch information
gotson committed May 19, 2023
1 parent 0c5a645 commit edb4b8a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/org/sqlite/SQLiteConnection.java
Expand Up @@ -14,6 +14,7 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;
import java.util.UUID;
import java.util.concurrent.Executor;
import org.sqlite.SQLiteConfig.TransactionMode;
import org.sqlite.core.CoreDatabaseMetaData;
Expand Down Expand Up @@ -304,7 +305,7 @@ private static File extractResource(URL resourceAddr) throws IOException {
}

String tempFolder = new File(System.getProperty("java.io.tmpdir")).getAbsolutePath();
String dbFileName = String.format("sqlite-jdbc-tmp-%d.db", resourceAddr.hashCode());
String dbFileName = String.format("sqlite-jdbc-tmp-%s.db", UUID.randomUUID());
File dbFile = new File(tempFolder, dbFileName);

if (dbFile.exists()) {
Expand Down

2 comments on commit edb4b8a

@osecen
Copy link

@osecen osecen commented on edb4b8a Sep 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using this library in one of our services and this code change causes our service to keep creating sqlite-jdbc-tmp-%s.db continuously and the service runs out of disk space. With this code, the old db is never deleted. Can we revert this commit please?

@gotson
Copy link
Collaborator Author

@gotson gotson commented on edb4b8a Sep 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't comment on commits

Please sign in to comment.