19 declare(strict_types=1);
47 protected const DATA =
'data';
56 bool $determine_linking_possible =
false 59 if ($determine_linking_possible) {
66 $random_filename =
"test_" . random_int(10000, 99999);
70 $cleaner =
function () use ($original_filename, $linked_filename):
void {
72 $this->fs->delete($original_filename);
76 $this->fs->delete($linked_filename);
86 $this->fs->write($original_filename,
'data');
87 $stream = $this->fs->readStream($original_filename);
90 $original_absolute_path = $stream->getMetadata(
'uri');
91 $linked_absolute_path = dirname((
string) $original_absolute_path) .
"/" . $random_filename .
'_link';
95 $linking = @
link($original_absolute_path, $linked_absolute_path);
97 $unlinking = @unlink($original_absolute_path);
99 if ($linking && $unlinking && $this->fs->has($linked_filename)) {
137 $DIC->upload()->moveOneFileTo(
158 $original_path = $revision->
getStream()->getMetadata(
'uri');
159 if ($this->links_possible) {
162 unlink($original_path);
169 unlink($original_path);
204 if ($this->fs->has(
$path)) {
205 $this->fs->delete(
$path);
207 $this->fs->writeStream(
$path, $stream);
229 return $this->fs->has($this->
getFlavourPath($revision, $flavour));
237 if ($this->fs->has(
$path)) {
238 $this->fs->deleteDir(
$path);
241 foreach ($storabel_flavour->
getStreams() as $index => $stream) {
243 $this->fs->writeStream($index_path, $stream);
252 if ($this->fs->has(
$path)) {
253 $this->fs->deleteDir(
$path);
263 if (!$this->
hasFlavour($revision, $flavour)) {
266 foreach ($this->fs->finder()->in([
$path])->files()->sortByName()->getIterator() as $item) {
267 yield $this->fs->readStream($item->getPath());
291 $first_level = strtok($container_path,
"/");
292 if (!empty($first_level)) {
293 $full_first_level = $storage_path .
'/' . $first_level;
294 $number_of_files = $this->fs->finder()->files()->in([$full_first_level])->count();
295 if ($number_of_files === 0) {
296 $this->fs->deleteDir($full_first_level);
309 .
'/' . self::FLAVOUR_PATH_PREFIX
315 $this->fs->deleteDir($this->
getRevisionPath($revision) .
'/' . self::FLAVOUR_PATH_PREFIX);
330 return $this->path_generator->getPathFor($identification);
340 return $this->links_possible ?
'link' :
'rename';
Class FileResourceHandler.
static createRelativePath(string $absolute_path)
Creates a relative path from an absolute path which starts with a valid storage location.
storeFlavour(Revision $revision, StorableFlavourDecorator $storabel_flavour)
hasFlavour(Revision $revision, Flavour $flavour)
Interface StorageResource.
const STORAGE
The filesystem outside of the ilias web root.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
streamReplacement(StreamReplacementRevision $revision)
getRevisionPath(Revision $revision)
This is the full path to a revision of a Resource, incl.
Class UploadedFileRevision.
const FLAVOUR_PATH_PREFIX
deleteFlavour(Revision $revision, Flavour $flavour)
cleanUpContainer(StorableResource $resource)
This checks if there are empty directories in the filesystem which can be deleted.
getContainerPathWithoutBase(ResourceIdentification $identification)
This is only the path of a ResourceIdentification inside the StorageLocation base path...
Class UploadedFileRevision.
Class UniqueIDIdentificationGenerator.
clearFlavours(Revision $revision)
__construct(protected Filesystem $fs, protected int $location=Location::STORAGE, bool $determine_linking_possible=false)
storeStream(FileStreamRevision $revision)
getFlavourPath(Revision $revision, Flavour $flavour)
cloneRevision(CloneRevision $revision)
deleteResource(StorableResource $resource)
IdentificationGenerator $id
Class ResourceIdentification.
Class AbstractFileSystemStorageHandler.
PathGenerator $path_generator
Class UniqueIDIdentificationGenerator.
static deriveLocationFrom(string $absolute_path)
has(ResourceIdentification $identification)
getFlavourStreams(Revision $revision, Flavour $flavour)
getFullContainerPath(ResourceIdentification $identification)
This is the full path to the container of a ResourceIdentification (incl.
getBasePath(ResourceIdentification $identification)
getPersistingName()
Flavours are stored in the file system by the StroageHandler.
getStorageLocationBasePath()
This is the place in the filesystem where the containers (nested) get created.
link(string $caption, string $href, bool $new_viewport=false)
storeUpload(UploadedFileRevision $revision)
getIdentificationGenerator()
The base interface for all filesystem streams.
getStream(Revision $revision)
deleteRevision(Revision $revision)
getAbsoluteRevisionPath(Revision $revision)