コード例 #1
0
 /**
  * Moves a file from somewhere to the expired trash heap
  *
  * @param Filesystem $filesystem
  * @param string     $filename
  * @param array      $config An optional configuration array
  *
  * @return bool
  */
 protected function moveToTrash(Filesystem $filesystem, $filename, array $config = [])
 {
     if (config('snapshot.soft-delete', EnterpriseDefaults::SNAPSHOT_SOFT_DELETE)) {
         $_trash = InstanceStorage::getTrashMount('expired');
         if ($_trash->writeStream($filename, $filesystem->readStream($filename), $config)) {
             return $filesystem->delete($filename);
         }
         //  Try and remove any partial file created before failure
         try {
             $_trash->delete($filename);
         } catch (\Exception $_ex) {
             //  Ignored, this is a cleanup in case of failure...
         }
     } else {
         try {
             if ($filesystem->has($filename)) {
                 return $filesystem->delete($filename);
             }
             //  It's gone
             return true;
         } catch (\Exception $_ex) {
             //  Can't delete? not good
             return false;
         }
     }
     return false;
 }
コード例 #2
0
ファイル: Instance.php プロジェクト: pkdevboxy/dfe-database
 /**
  * @param string|null $append Optional path to append
  * @param bool        $create Create if non-existent
  *
  * @return \League\Flysystem\Filesystem
  */
 public function getTrashMount($append = null, $create = true)
 {
     return InstanceStorage::getTrashMount($append, $create);
 }