freenet / freenet-core

Declare your digital independence
https://freenet.org/
Apache License 2.0
2.28k stars 78 forks source link

temp_dir content preserved #206

Closed kakoc closed 2 years ago

kakoc commented 2 years ago

While developing locally temp_dir() is used. So I faced with the issue when I changed my html files but they won't applied for new run just because files in temp dir preserved(in my case it was: /var/...locutus/webs/...; m1 Monterey platform) I needed explicitly rm -rf /var/.../locutus So probably we need to do some cleanup when exit? Also I faced with the issue when I changed some file and I need to run bunch of comands(recompile web/data contract/data and move into examples) Since it's an active development as a quick solution - does it make sense to introduce some Makefile/bashscript for that? Something like that:

#!/usr/bin/bash

# clean locutus temp_dir; could be evaluated dynamically
rm -rf /var/folders/4g/x2ybv6lj4s794_j2w41d6j_r0000gn/T/locutus/

cd crates/http-gw/examples
rm freenet_microblogging_data
rm freenet_microblogging_data.wasm
rm freenet_microblogging_web
rm freenet_microblogging_web.wasm
cd ../../..

cargo build 

cd contracts/freenet-microblogging-web
bash compile_contract.sh    
mv ./freenet_microblogging_web.wasm ../../crates/http-gw/examples/
cd ../..

cd contracts/freenet-microblogging-data
bash compile_contract.sh    
mv freenet_microblogging_data.wasm ../../crates/http-gw/examples/
cd ../..

cd crates/locutus-dev
cargo run --bin build_state -- --input-path ../../contracts/freenet-microblogging-web/web --output-file ../http-gw/examples/freenet_microblogging_web --contract-type web
cargo run --bin build_state -- --input-path ../../contracts/freenet-microblogging-data --output-file ../http-gw/examples/freenet_microblogging_data --contract-type data
cd ../..

We also can place a temp dir clean command there

iduartgomez commented 2 years ago

Preserving things is on pourpouse since even under local development you will want most probably to keep state across different executions of the same contract to emulate how things would work in a real environment.

What we could do is add a commad line parameter for when the local node is executed to perform a tear down of any state which is kept alive. I would rather do that that introduce scripts just for it, as it seems more portable and maintainable and it makes sense to give those options to the developer (I also have faced similar situations where I had to clean manually any output to have a blank slate, but other tiems you want to keep previous state around, so I think having the flexibility is good).

kakoc commented 2 years ago

Adding a command line argument sounds good. I can tackle on it.

But what do you think about automated build of the dev contracts for dev purposes like I mentioned above via bash file?

iduartgomez commented 2 years ago

But what do you think about automated build of the dev contracts for dev purposes like I mentioned above via bash file?

Yes we will need scripts for those eventually when we enable them at the CI level and add them to testing pipelines.

Which because rising popularity we shall do sooner rather than later. But we can pick up on that later.