alem0lars / fizzy

The hassle free configuration manager - MIGRATED TO https://gitlab.com/fizzycfg
Other
11 stars 3 forks source link

Fizzy install links temporary files #25

Open alem0lars-yr opened 8 years ago

alem0lars-yr commented 8 years ago

Fizzy install links temporary files..

2016-07-01-232342_1266x825_scrot

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/35682418-fizzy-install-links-temporary-files?utm_campaign=plugin&utm_content=tracker%2F10471801&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F10471801&utm_medium=issues&utm_source=github).
alem0lars commented 8 years ago

The bug may be present only when there are conflicts to be resolved.

In fact, the conflict resolution is handled internally by thor that uses the block form for creating the temporary file.

Taking a look at the ruby documentation we see:

Tempfile.open('foo', '/home/temp') do |f|
   ... do something with f ...
end

# Equivalent:
f = Tempfile.open('foo', '/home/temp')
begin
   ... do something with f ...
ensure
   f.close
end

This shows that internally uses: f.close:

close(unlink_now=false)

Closes the file. If unlink_now is true, then the file will be unlinked (deleted) after closing. Of course, you can choose to later call unlink if you do not unlink it now.

If you don’t explicitly unlink the temporary file, the removal will be delayed until the object is finalized.

As we can see the problem may be that unlink_now is set to false, the removal will be delayed until the object is finalized.

In conclusion, the file isn't removed instantly but instead when the Ruby's VM decides to dispose the object.

This could be the problem since right after the instatiation we trigger the installation that links every file available there, including the fucking temporary file.

alem0lars commented 8 years ago

@jak3 what do you think about?

jak3 commented 8 years ago

Maybe remove thor should be an option. How much work do you think is needed in order to replace it functionalities?

alem0lars commented 8 years ago

I'd really like to remove thor, this will allow us to implement ad-hoc features and to be dependency-less.. However, it costs a lot of time because we need to implement a custom command-based parser (similar to thor) and custom low level I/O operations.. Also removing thor enables us to solve some more issues related to that gem.