19declare(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);
73 }
catch (\Throwable) {
76 $this->fs->delete($linked_filename);
77 }
catch (\Throwable) {
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)) {
105 }
catch (\Throwable) {
137 $DIC->upload()->moveOneFileTo(
139 $this->getRevisionPath($revision),
158 $original_path = $revision->
getStream()->getMetadata(
'uri');
159 if ($this->links_possible) {
162 unlink($original_path);
169 unlink($original_path);
179 }
catch (\Throwable) {
192 }
catch (\Throwable) {
204 if ($this->fs->has(
$path)) {
205 $this->fs->delete(
$path);
207 $this->fs->writeStream(
$path, $stream);
209 }
catch (\Throwable) {
223 }
catch (\Throwable) {
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());
279 }
catch (\Throwable) {
283 }
catch (\Throwable) {
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';
The legacy path helper provides convenient functions for the integration of the filesystem service wi...
static createRelativePath(string $absolute_path)
Creates a relative path from an absolute path which starts with a valid storage location.
static deriveLocationFrom(string $absolute_path)
getPersistingName()
Flavours are stored in the file system by the StroageHandler.
Class ResourceIdentification.
Class UniqueIDIdentificationGenerator.
Class UploadedFileRevision.
Class UploadedFileRevision.
Class AbstractFileSystemStorageHandler.
const FLAVOUR_PATH_PREFIX
deleteFlavour(Revision $revision, Flavour $flavour)
getContainerPathWithoutBase(ResourceIdentification $identification)
This is only the path of a ResourceIdentification inside the StorageLocation base path.
cloneRevision(CloneRevision $revision)
storeStream(FileStreamRevision $revision)
@inheritDoc
has(ResourceIdentification $identification)
getBasePath(ResourceIdentification $identification)
getFlavourPath(Revision $revision, Flavour $flavour)
hasFlavour(Revision $revision, Flavour $flavour)
deleteResource(StorableResource $resource)
@inheritDoc
getIdentificationGenerator()
@inheritDoc
getStream(Revision $revision)
@inheritDoc
IdentificationGenerator $id
getRevisionPath(Revision $revision)
This is the full path to a revision of a Resource, incl.
PathGenerator $path_generator
streamReplacement(StreamReplacementRevision $revision)
storeFlavour(Revision $revision, StorableFlavourDecorator $storabel_flavour)
getFlavourStreams(Revision $revision, Flavour $flavour)
clearFlavours(Revision $revision)
getFullContainerPath(ResourceIdentification $identification)
This is the full path to the container of a ResourceIdentification (incl.
deleteRevision(Revision $revision)
@inheritDoc
__construct(protected Filesystem $fs, protected int $location=Location::STORAGE, bool $determine_linking_possible=false)
storeUpload(UploadedFileRevision $revision)
getAbsoluteRevisionPath(Revision $revision)
cleanUpContainer(StorableResource $resource)
This checks if there are empty directories in the filesystem which can be deleted.
const STORAGE
The filesystem outside of the ilias web root.
The filesystem interface provides the public interface for the Filesystem service API consumer.
The base interface for all filesystem streams.
Class UniqueIDIdentificationGenerator.
Interface StorageResource.
Class FileResourceHandler.
getStorageLocationBasePath()
This is the place in the filesystem where the containers (nested) get created.
link(string $caption, string $href, bool $new_viewport=false)