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

change stats.radata file #1161

Merged
merged 3 commits into from
Nov 23, 2021
Merged

change stats.radata file #1161

merged 3 commits into from
Nov 23, 2021

Conversation

resession
Copy link
Contributor

fs.writeFile(__dirname+'/../stats.'+(root.opt.file || file), raw, function(err){ W = false; err && console.log(console.STAT.err = err); console.STAT && console.STAT(S, +new Date - S, 'stats stash') });

the above line is what creates the following error:
Error: ENOENT: no such file or directory, open 'C:\Project\gundb\tests\node_modules\gun\stats.C:\Project\gundb\testingFolder'

does the stats.radata need to be the root.opt.file? because if someone inputs a file directory like C:\some\path\here, it will make the stats file into 'stats.C:\some\path\here' which i think is the problem for fs.write functions. what i did is create the stats.radata file only in the gun directory, tested it and i get no errors now. will this be satisfactory?

@resession
Copy link
Contributor Author

resession commented Nov 13, 2021

it tries to create a file called "stats.C:\Project\gundb\testingFolder", that is why fs.writeFile is having issues, that is not a valid filename. so i changed it to "stats.radata"

@amark
Copy link
Owner

amark commented Nov 14, 2021

@resession excellent! This is actually how it worked originally, but it caused problems when running the PANIC tests (or any time someone runs 2 versions of GUN on the same machine).

2 versions of GUN started in the same directory will both attempt to write to the same 1 database file/folder, which breaks/crashes stuff. The same "clobbering" happens for the stats system.

So to launch 2 versions of GUN (which PANIC does for testing multi-peer setups), peer 1 Alice needs to call herself GUN({file: "alice" and peer 2 needs to call herself GUN({file: "bob"

The stats data is not important tho, so I can accept this PR as-is, but would you be willing to modify it slightly further? If you want the data in a separate directory, maybe the stats data should be saved to ../stats relative to the provided path? Or maybe still keep saving it to the gun folder but just do an .split('/').slice(-1)[0] so it uses the last path name to prevent the alice vs bob collision?

THANK YOU SO MUCH FOR HELPING WITH THIS!!!! <3 <3 <3

@resession
Copy link
Contributor Author

resession commented Nov 14, 2021

does the new change work? i brought in the path module to use path.resolve. in case someone uses a literal '\' separator(which will throw off the .split('/')). also using path.sep, that way we are using the os's separator. if opt.file has not been passed in, then we will use 'radata' by default.

i chose to save the stats file in the gun folder, reason being is i think gun related things should stay close to the gun folder itself. tested this, works good.

thanks for the good words, love seeing gundb and projects like it

@amark
Copy link
Owner

amark commented Nov 23, 2021

@resession 👏 <3 Thank you!!!! Sorry was busy last week. Merging!!! THANK YOU.

@amark amark merged commit 396b367 into amark:master Nov 23, 2021
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

Successfully merging this pull request may close these issues.

2 participants