Skip to content

Commit

Permalink
handle deleting a file in a collection
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyiq committed Apr 9, 2024
1 parent 2f10de3 commit 8c2c057
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion classes/data/File.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ public static function create(Transfer $transfer, $name = null, $size = null, $m
public function beforeDelete()
{
Storage::deleteFile($this);

FileCollection::removeFile( $this );
Logger::info($this.' deleted');
}

Expand Down
6 changes: 6 additions & 0 deletions classes/data/FileCollection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,12 @@ public function delete()
$s->execute(array(':collection_id' => $this->collection_id,
':file_id' => $this->file_id));
}

public static function removeFile( $file )
{
$s = DBI::prepare('DELETE FROM '.static::getDBTable().' WHERE file_id = :file_id');
$s->execute(array(':file_id' => $file->id));
}

/**
* Getter
Expand Down

0 comments on commit 8c2c057

Please sign in to comment.