Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

fix: fix db write error on partitioned drives #548

Merged
merged 2 commits into from
Feb 12, 2020

Conversation

davidmurdoch
Copy link
Member

This is an attempt to fix https://github.com/trufflesuite/ganache/issues/1617

If the user's tmp dir and ganache's db directory is not located on the same drive/partition then db file writes fail. This fixes that issue by ensuring the tmp directory is one we control (obviously this means automatic tmp file deletion by the os won't happen in cases where the user has supplied their own db path (like Ganache UI does automatically), but we don't need to worry about that unless ganache crashes, and even then, I don't think it is an issue as only a few key/value files would accumulate there in these exceptional circumstances).

All that said... I haven't yet tested this since it requires some filesystem shenanigans I don't want to set up on a Saturday afternoon.

TODO before merging: actually test that this fixes anything. :-D

@coveralls
Copy link

coveralls commented Feb 8, 2020

Coverage Status

Coverage increased (+0.007%) to 82.122% when pulling d6698aa on fix/db-partition-error into 9d50099 on develop.

Copy link
Contributor

@nicholasjpaterno nicholasjpaterno left a comment

Choose a reason for hiding this comment

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

LGTM!

lib/database/filedown.js Show resolved Hide resolved
@davidmurdoch
Copy link
Member Author

I've tested this manually by setting the db_path of a ganache-core instance to a directory located on a USB drive. Before this change it would fail, after it doesn't.

@@ -11,6 +11,7 @@ function FileDown(location) {
this.location = location;
const tmpDir = path.join(location, "_tmp");
try {
// Fixes https://github.com/trufflesuite/ganache/issues/1617
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants