Hi devs,
Right now we have <PERMDIR>/cache
(data that can be deleted with no impact) and <PERMDIR>/store
(permanent data).
However we have a 3rd category that force each extension needing it to create a top level entry in the PERMDIR: work data.
For example:
- Prepared mails that are waiting to be sent
- Mentions queue waiting for docs to be analyzed for mentions
I’m thus proposing that we add a new <PERMDIR>/work
directory for that type of data.
WDYT?
Thanks
The proposal is actually not complete since we need to handle the existing situation too.
I propose the following:
-
New code introduced after this proposal is agreed will use the new work/
directory
-
Best effort for existing code, which means either leave them as it is or migrate them to the new directory. This means writing a “DB” migration (so that it’s one off) to move the existing directory to the new location.
import static java.nio.file.StandardCopyOption.*;
Files.move(new File("C:\\projects\\test").toPath(), new File("C:\\projects\\dirTest").toPath(), StandardCopyOption.REPLACE_EXISTING);
WDYT?
BTW we also need some typed API for these directories. Right now we have:
public interface Environment {
File getTemporaryDirectory();
File getPermanentDirectory();
URL getResource(String resourceName);
InputStream getResourceAsStream(String resourceName);
}
Maybe add PermanentDirectories getPermanentDirectories()
with:
public interface PermanentDirectories
{
File getWorkDirectory();
File getCacheDirectory();
File getStoreDirectory();
}
BTW, I’m not very clear about the difference between the cache
directory in the perm dir and the temporary directory. It seems to me that a cache is a temporary directory and that it can be safely removed. Maybe temporary has a shorter lifespan than cache?
Thanks
Could also be good to have an API to create a new directory with a uniquely-generated name (for storing stuff in the tmp dir for ex).
For me if you store something that you plan to reuse after a restart but can be recreated if lost it’s a cache. If you don’t plan to reuse it after a restart then it’s tmp.
Was agreed but not action was done. I’ve created Loading... to implement it.