Feature #62830

Epic #83669: Improve file list / file browser

Improved folder moving/copying

Added by Christian Opitz about 4 years ago. Updated 8 months ago.

Status:
Under Review
Priority:
Must have
Category:
File Abstraction Layer (FAL)
Start date:
2014-11-10
Due date:
% Done:

0%

PHP Version:
Tags:
Complexity:
medium
Sprint Focus:

Description

The methods for moving and copying in TYPO3\CMS\Core\Resource\ResourceStorage require several improvements:
  1. Implement moving and copying folders between storages
  2. Implement conflict handling for moving and copying folders
    • renameNewFolder would generate another name for the target folder, when it already exists at target parent
    • renameNewFile would add new directories and add the files with new names, when they already exist
    • integrate would add new directories and overwrite existing files
    • cancel would cancel
  3. Implement a way to allow custom drivers to import files from other drivers/storages rather than forcing it to add a local copy (see thread on mailing list for upfront discussions):
    Will provide an TYPO3\CMS\Core\Resource\Driver\ImportableDriverInterface with importFile(\TYPO3\CMS\Core\Resource\FileInterface $file, $targetFolderIdentifier, $newFileName = null, $removeOriginal = TRUE). When the driver implements this interface, this method instead of addFile() will be called in ResourceStorage::moveFile() and ResourceStorage::copyFile()
  4. Allow to moveFile/moveFolder without removing the source file (usefull for migrations between two different drivers)
  5. Create functional tests for the move and copy methods

Related issues

Related to TYPO3 Core - Bug #65983: Clipboard does not work between two filestorages Closed 2015-03-24
Related to TYPO3 Core - Bug #64363: Copy files in Filelist backend Accepted 2015-01-19
Related to TYPO3 Core - Feature #66514: Better UI to move multiple files or folders New 2015-04-21

History

#1 Updated by Gerrit Code Review about 4 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33955

#2 Updated by Gerrit Code Review about 4 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33955

#3 Updated by Gerrit Code Review about 4 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33955

#4 Updated by Gerrit Code Review about 4 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33955

#5 Updated by Gerrit Code Review about 4 years ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33955

#6 Updated by Gerrit Code Review about 4 years ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33955

#7 Updated by Gerrit Code Review about 4 years ago

Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33955

#8 Updated by Gerrit Code Review about 4 years ago

Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33955

#9 Updated by Christian Opitz about 4 years ago

The most basic ImportableDriver would just call addFile (untested):

<?php
namespace TYPO3\CMS\Core\Resource\Driver;

class LocalImportableDriver extends LocalDriver implements ImportableDriverInterface {
    /**
     * Add an already existing FAL File from another storage
     *
     * @param \TYPO3\CMS\Core\Resource\FileInterface $file
     * @param string $targetFolderIdentifier
     * @param string $newFileName optional, if not given original name is used
     * @return string The new identifier
     */
    public function importFile(\TYPO3\CMS\Core\Resource\FileInterface $file, $targetFolderIdentifier, $newFileName = NULL) {
        return $this->addFile(
            $file->getForLocalProcessing(FALSE),
            $targetFolderIdentifier,
            $newFileName,
            FALSE
        );
    }
}

A more sophisticated one, could download the files from another storage (untested):

<?php
namespace TYPO3\CMS\Core\Resource\Driver;

use TYPO3\CMS\Core\Utility\GeneralUtility;

class LocalImportableDriver extends LocalDriver implements ImportableDriverInterface {
    /**
     * Change to suit your host
     */
    const IMPORT_SOURCE_BASE = 'http://localhost';

    /**
     * Add an already existing FAL File from another storage
     *
     * @param \TYPO3\CMS\Core\Resource\FileInterface $file
     * @param string $targetFolderIdentifier
     * @param string $newFileName optional, if not given original name is used
     * @return string The new identifier
     */
    public function importFile(\TYPO3\CMS\Core\Resource\FileInterface $file, $targetFolderIdentifier, $newFileName = NULL) {        
        $newFileName = $this->sanitizeFileName($newFileName ? $newFileName : $file->getName());
        $newFileIdentifier = $this->canonicalizeAndCheckFolderIdentifier($targetFolderIdentifier) . $newFileName;
        $targetPath = $this->absoluteBasePath . $newFileIdentifier;

        $handle = fopen(self::IMPORT_SOURCE_BASE . $file->getPublicUrl(), 'r');
        if (!$handle) {
            throw new \RuntimeException('Could not open file via URL');
        }

        if (!file_put_contents($targetPath, $handle) || !file_exists($targetPath)) {
            throw new \RuntimeException('Adding file ' . $localFilePath . ' at ' . $newFileIdentifier . ' failed.');
        }

        clearstatcache();
        GeneralUtility::fixPermissions($targetPath);

        return $newFileIdentifier;
    }
}

#10 Updated by Mathias Schreiber almost 4 years ago

  • Target version changed from 7.0 to 7.1 (Cleanup)

#11 Updated by Markus Klein over 3 years ago

  • Target version changed from 7.1 (Cleanup) to 7.4 (Backend)
  • Complexity set to medium
Two things:
  1. If I move a folder /foo/bla. There must not be a paste sign on the /foo folder. Neither in list-view on the folder / nor in the toolbar when in folder /foo
  2. If I copy a folder /foo/bla. Then there must be a check if the folder already exists, when I try to paste it into /foo again (edited)

#12 Updated by Susanne Moog over 3 years ago

  • Target version changed from 7.4 (Backend) to 7.5

#13 Updated by Benni Mack about 3 years ago

  • Target version changed from 7.5 to 7 LTS

#14 Updated by Gerrit Code Review about 2 years ago

Patch set 9 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/33955

#15 Updated by Michael Oehlhof about 2 years ago

  • Target version changed from 7 LTS to 8 LTS

#16 Updated by Gerrit Code Review about 2 years ago

Patch set 10 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/33955

#17 Updated by Gerrit Code Review about 2 years ago

Patch set 11 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/33955

#18 Updated by Gerrit Code Review about 2 years ago

Patch set 12 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/33955

#19 Updated by Gerrit Code Review about 2 years ago

Patch set 13 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/33955

#20 Updated by Gerrit Code Review about 2 years ago

Patch set 14 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/33955

#21 Updated by Gerrit Code Review about 2 years ago

Patch set 15 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/33955

#22 Updated by Gerrit Code Review about 2 years ago

Patch set 16 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/33955

#23 Updated by Gerrit Code Review about 2 years ago

Patch set 17 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/33955

#24 Updated by Gerrit Code Review about 2 years ago

Patch set 18 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/33955

#25 Updated by Gerrit Code Review about 2 years ago

Patch set 19 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/33955

#26 Updated by Riccardo De Contardi almost 2 years ago

  • Target version changed from 8 LTS to 9.0

#27 Updated by Riccardo De Contardi 11 months ago

  • Related to Feature #66514: Better UI to move multiple files or folders added

#28 Updated by Riccardo De Contardi 11 months ago

  • Parent task set to #83669

#29 Updated by Susanne Moog 11 months ago

  • Target version changed from 9.0 to 9.2

#30 Updated by Susanne Moog 8 months ago

  • Target version changed from 9.2 to Candidate for Major Version

Also available in: Atom PDF