mirror of
https://github.com/openvk/openvk
synced 2024-11-11 01:19:53 +03:00
Media: Allow to change the default data deletion policy
This commit is contained in:
parent
403ed65bd1
commit
240ce51705
2 changed files with 30 additions and 0 deletions
|
@ -89,4 +89,21 @@ abstract class Media extends Postable
|
|||
|
||||
$this->stateChanges("hash", $hash);
|
||||
}
|
||||
|
||||
function delete(bool $softly = true): void
|
||||
{
|
||||
$deleteQuirk = ovkGetQuirk("blobs.erase-upon-deletion");
|
||||
if($deleteQuirk === 2 || ($deleteQuirk === 1 && !$softly))
|
||||
@unlink($this->getFileName());
|
||||
|
||||
parent::delete($softly);
|
||||
}
|
||||
|
||||
function undelete(): void
|
||||
{
|
||||
if(ovkGetQuirk("blobs.erase-upon-deletion") === 2)
|
||||
throw new \LogicException("Can't undelete model which is tied to blob, because of config constraint (quriks.yml:blobs.erase-upon-deletion)");
|
||||
|
||||
parent::undelete();
|
||||
}
|
||||
}
|
||||
|
|
13
quirks.yml
13
quirks.yml
|
@ -12,3 +12,16 @@
|
|||
# + Set this option to 1 if you want to use quirky OpenVK behaviour
|
||||
# + Set this option to 0 if you want to use the canonical VK behaviour
|
||||
profile.rating-bar-behaviour: 0
|
||||
|
||||
# Blob deletion behaviour
|
||||
# Current VK and old OpenVK don't delete files automatically,
|
||||
# thus leaving ability to access user-deleted medias by direct URL.
|
||||
# This config option allows to change this.
|
||||
#
|
||||
# Possible values:
|
||||
# + Set this option to 2 if you want to delete files upon user-initiated deletion
|
||||
# (this option will prohibit restoring any deleted media)
|
||||
# + Set this option to 1 if you want to delete files once they're removed from DB completely
|
||||
# (this option most likely won't have any meaningful effect, please use option 2)
|
||||
# + Set this option to 0 if you want to use quirky VK and OpenVK behaviour
|
||||
blobs.erase-upon-deletion: 0
|
||||
|
|
Loading…
Reference in a new issue