mirror of
https://framagit.org/fiat-tux/hat-softwares/lutim.git
synced 2026-08-07 01:12:49 +02:00
Fix #27
This commit is contained in:
@@ -76,6 +76,7 @@ The `lutim.conf.template` is self-documented but here is the options that you ca
|
||||
* default\_delay: what is the default time limit for files? Valid values are 0, 1, 7, 30 and 365;
|
||||
* max\_delay: if defined, the images will be deleted after that delay (in days), even if they were uploaded with "no delay" (or value superior to max\_delay) option and a warning message will be displayed on homepage;
|
||||
* always\_encrypt: if set to 1, all images will be encrypted.
|
||||
* delete\_no\_longer\_viewed\_files: if set, the images which have not been viewed since `delete\_no\_longer\_viewed\_files` days will be deleted by the `script/lutim cron cleanfiles` command
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -147,6 +148,7 @@ carton exec script/lutim cron cleanbdd
|
||||
|
||||
### Delete expired files
|
||||
To automatically delete files which availability delay is over (when you choose that your image will be deleted after 24h / one week / etc.)
|
||||
If `delete\_no\_longer\_viewed\_files`, the files not viewed since `delete\_no\_longer\_viewed\_files` days will be deleted too.
|
||||
```shell
|
||||
carton exec script/lutim cron cleanfiles
|
||||
```
|
||||
|
||||
@@ -16,6 +16,18 @@ sub run {
|
||||
$image->update(enabled => 0);
|
||||
unlink $image->path();
|
||||
}
|
||||
|
||||
my $config = $c->app->plugin('Config');
|
||||
|
||||
if (defined($config->{delete_no_longer_viewed_files}) && $config->{delete_no_longer_viewed_files} > 0) {
|
||||
$time = time() - $config->{delete_no_longer_viewed_files} * 86400;
|
||||
@images = LutimModel::Lutim->select('WHERE enabled = 1 AND last_access_at < ?', $time);
|
||||
|
||||
for my $image (@images) {
|
||||
$image->update(enabled => 0);
|
||||
unlink $image->path();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
=encoding utf8
|
||||
|
||||
@@ -119,4 +119,9 @@
|
||||
# please, see readme
|
||||
# optional, default is 'warn'
|
||||
#policy_when_full => 'warn',
|
||||
|
||||
# images which are not viewed since delete_no_longer_viewed_files days will be deleted by the cron cleanfiles task
|
||||
# if delete_no_longer_viewed_files is not set, the no longer viewed files will NOT be deleted
|
||||
# optional, no default
|
||||
#delete_no_longer_viewed_files => 90
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user