Add initial support for deleted paths

This commit is contained in:
Luke Towers 2018-11-05 16:02:12 -06:00
parent 32c7891942
commit 65e0c9d7b6
2 changed files with 19 additions and 3 deletions

View File

@ -83,10 +83,19 @@ class AutoDatasource extends Datasource implements DatasourceInterface
// Default to the last datasource provided
$datasourceIndex = count($this->datasources) - 1;
$isDeleted = false;
foreach ($this->pathCache as $i => $paths) {
if (in_array($path, $paths)) {
if (isset($paths[$path])) {
$datasourceIndex = $i;
}
// Set isDeleted to the inverse of the the path's existance flag
$isDeleted = !$paths[$path];
}
}
if ($isDeleted) {
throw new Exception("$path is deleted");
}
return $this->datasources[$datasourceIndex];
@ -115,7 +124,13 @@ class AutoDatasource extends Datasource implements DatasourceInterface
*/
public function selectOne($dirName, $fileName, $extension)
{
return $this->getDatasourceForPath($this->makeFilePath($dirName, $fileName, $extension))->selectOne($dirName, $fileName, $extension);
try {
$result = $this->getDatasourceForPath($this->makeFilePath($dirName, $fileName, $extension))->selectOne($dirName, $fileName, $extension);
} catch (Exception $ex) {
$result = null;
}
return $result;
}
/**

View File

@ -15,6 +15,7 @@ class DbCmsThemeContents extends Migration
$table->longText('content');
$table->integer('file_size')->unsigned();
$table->dateTime('updated_at')->nullable();
$table->dateTime('deleted_at')->nullable();
});
}