|
@@ 103-116 (lines=14) @@
|
| 100 |
|
* |
| 101 |
|
* @param string $spiBinaryFileId |
| 102 |
|
*/ |
| 103 |
|
public function delete($spiBinaryFileId) |
| 104 |
|
{ |
| 105 |
|
$path = $this->addPrefix($spiBinaryFileId); |
| 106 |
|
|
| 107 |
|
// Unlike the legacy cluster, the file is directly deleted. It was inherited from the DB cluster anyway |
| 108 |
|
$stmt = $this->db->prepare('DELETE FROM ezdfsfile WHERE name_hash LIKE :name_hash'); |
| 109 |
|
$stmt->bindValue('name_hash', md5($path)); |
| 110 |
|
$stmt->execute(); |
| 111 |
|
|
| 112 |
|
if ($stmt->rowCount() != 1) { |
| 113 |
|
// Is this really necessary ? |
| 114 |
|
throw new BinaryFileNotFoundException($path); |
| 115 |
|
} |
| 116 |
|
} |
| 117 |
|
|
| 118 |
|
/** |
| 119 |
|
* Loads and returns metadata for $spiBinaryFileId. |
|
@@ 155-164 (lines=10) @@
|
| 152 |
|
* |
| 153 |
|
* @return bool |
| 154 |
|
*/ |
| 155 |
|
public function exists($spiBinaryFileId) |
| 156 |
|
{ |
| 157 |
|
$path = $this->addPrefix($spiBinaryFileId); |
| 158 |
|
|
| 159 |
|
$stmt = $this->db->prepare('SELECT name FROM ezdfsfile WHERE name_hash LIKE ? and mtime > 0 and expired != 1'); |
| 160 |
|
$stmt->bindValue(1, md5($path)); |
| 161 |
|
$stmt->execute(); |
| 162 |
|
|
| 163 |
|
return ($stmt->rowCount() == 1); |
| 164 |
|
} |
| 165 |
|
|
| 166 |
|
/** |
| 167 |
|
* @param SPIBinaryFileCreateStruct $binaryFileCreateStruct |
|
@@ 227-240 (lines=14) @@
|
| 224 |
|
return isset($this->urlDecorator) ? $this->urlDecorator->undecorate($prefixedId) : $prefixedId; |
| 225 |
|
} |
| 226 |
|
|
| 227 |
|
public function getMimeType($spiBinaryFileId) |
| 228 |
|
{ |
| 229 |
|
$stmt = $this->db->prepare('SELECT * FROM ezdfsfile WHERE name_hash LIKE ? AND expired != 1 AND mtime > 0'); |
| 230 |
|
$stmt->bindValue(1, md5($this->addPrefix($spiBinaryFileId))); |
| 231 |
|
$stmt->execute(); |
| 232 |
|
|
| 233 |
|
if ($stmt->rowCount() == 0) { |
| 234 |
|
throw new BinaryFileNotFoundException($spiBinaryFileId); |
| 235 |
|
} |
| 236 |
|
|
| 237 |
|
$row = $stmt->fetch(\PDO::FETCH_ASSOC); |
| 238 |
|
|
| 239 |
|
return $row['datatype']; |
| 240 |
|
} |
| 241 |
|
|
| 242 |
|
public function deleteDirectory($spiPath) |
| 243 |
|
{ |
|
@@ 289-298 (lines=10) @@
|
| 286 |
|
* @param string $scope The file scope, one of 'binaryfile', 'image', 'mediafile' |
| 287 |
|
* @return int |
| 288 |
|
*/ |
| 289 |
|
public function count($scope) |
| 290 |
|
{ |
| 291 |
|
$stmt = $this->db->prepare('SELECT count(name_hash) as count FROM ezdfsfile WHERE scope LIKE ? AND expired != 1 AND mtime > 0'); |
| 292 |
|
$stmt->bindValue(1, $scope); |
| 293 |
|
$stmt->execute(); |
| 294 |
|
|
| 295 |
|
$row = $stmt->fetch(\PDO::FETCH_ASSOC); |
| 296 |
|
|
| 297 |
|
return (int)$row['count']; |
| 298 |
|
} |
| 299 |
|
} |
| 300 |
|
|