/** * Update node meta after removing file * @param $fileInfo InputFile * @return bool */ public function remove($fileInfo) { /** @var NodeMeta $node */ $node = $this->model->ofId($fileInfo->nodeId); if ($node) { return $this->model->updateOne($node->id, ['fileCount' => $node->fileCount - 1, 'volume' => $node->volume - $fileInfo->size]); } return false; }
/** * @param $fid * @return InputFile */ public function decrFileRefCountById($fid) { /** @var static $row */ $row = $this->model->ofId($fid); $row->refCount--; $fileInfo = InputFile::initWithFileMeta($row); if ($row->refCount == 0) { $this->model->deleteById($row->id); } else { $this->model->updateOne($row->id, ['refCount' => $row->refCount]); } return $fileInfo; }