Open sjkisner opened 3 years ago
So, every-time we run recon or project, we should 'touch' the sysmatrix file?
Yes, that way its time stamp will update.
We can just do it in one place, under the line that prints "Found system matrix".
Not sure "touch" will work in Windows though unless it's run in a bash emulator.
There's a useful discussion here on how to implement touch
in an OS-independent fashion.
Yes! This works for me on Linux,Mac,Windows: import os os.utime(sysmatrix_name+'.2Dsvmatrix')
The above is all we need here because we just need to update the modified time for a file that exists.
OK, we have added a touch
command that updates the last modification time for the library files.
After some thought, maybe it would be best to create a separate utility svmbir.clean_lib(N)
that would clean out the library and only retain the N
most recent files.
Do people like this idea?
Sounds good. There's already a function _clear_cache() that could be modified.
I'd suggest having it default to cleaning the cache folder entirely. Like
clear_cache(svmbir_lib_path=None, num_sysmatrix=0)
where num_sysmatrix is number of most recent matrix files.
We should take care to identify the specified path as a valid cache folder so it can't be used to obliterate an arbitrary folder.
We should implement a function clear_cache()
that first prompts the user with something like:
Would you like to delete your cache directory? [y/n]
Then if the user responds with a y
, it calls _clear_cache()
.
Brendts suggestion: Perhaps allow the user to specify a maximum cache size? If writing a new file exceeds it, automatically delete the oldest files until it's under the threshold?
Add functions to "list" and "clear" sysmatrix files from cache directory.
We should use "touch" or something equivalent to update the time stamp of the sysmatrix file each time it's accessed in order to assigning priority.