当前位置: 首页>>代码示例>>PHP>>正文


PHP Storage::remove方法代码示例

本文整理汇总了PHP中OC\Files\Cache\Storage::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP Storage::remove方法的具体用法?PHP Storage::remove怎么用?PHP Storage::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OC\Files\Cache\Storage的用法示例。


在下文中一共展示了Storage::remove方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: removeStorage

 /**
  * Delete the storage with the given id.
  *
  * @param int $id storage id
  *
  * @throws NotFoundException if no storage was found with the given id
  */
 public function removeStorage($id)
 {
     $existingMount = $this->dbConfig->getMountById($id);
     if (!is_array($existingMount)) {
         throw new NotFoundException('Storage with id "' . $id . '" not found');
     }
     $this->dbConfig->removeMount($id);
     $deletedStorage = $this->getStorageConfigFromDBMount($existingMount);
     $this->triggerHooks($deletedStorage, Filesystem::signal_delete_mount);
     // delete oc_storages entries and oc_filecache
     try {
         $rustyStorageId = $this->getRustyStorageIdFromConfig($deletedStorage);
         \OC\Files\Cache\Storage::remove($rustyStorageId);
     } catch (\Exception $e) {
         // can happen either for invalid configs where the storage could not
         // be instantiated or whenever $user vars where used, in which case
         // the storage id could not be computed
         \OCP\Util::writeLog('files_external', 'Exception: "' . $e->getMessage() . '"', \OCP\Util::ERROR);
     }
 }
开发者ID:loulancn,项目名称:core,代码行数:27,代码来源:storagesservice.php

示例2: fixLegacyStorage

 /**
  * Fix the given legacy storage by renaming the old id
  * to the new id. If the new id already exists, whichever
  * storage that has data in the file cache will be used.
  * If both have data, nothing will be done and false is
  * returned.
  *
  * @param string $oldId old storage id
  * @param int $oldNumericId old storage numeric id
  * @param string $userId
  * @return bool true if fixed, false otherwise
  * @throws RepairException
  */
 private function fixLegacyStorage($oldId, $oldNumericId, $userId = null)
 {
     // check whether the new storage already exists
     if (is_null($userId)) {
         $userId = $this->extractUserId($oldId);
     }
     $newId = 'home::' . $userId;
     // check if target id already exists
     $newNumericId = Storage::getNumericStorageId($newId);
     if (!is_null($newNumericId)) {
         $newNumericId = (int) $newNumericId;
         // try and resolve the conflict
         // check which one of "local::" or "home::" needs to be kept
         $this->findStorageInCacheStatement->execute(array($oldNumericId, $newNumericId));
         $row1 = $this->findStorageInCacheStatement->fetch();
         $row2 = $this->findStorageInCacheStatement->fetch();
         $this->findStorageInCacheStatement->closeCursor();
         if ($row2 !== false) {
             // two results means both storages have data, not auto-fixable
             throw new RepairException('Could not automatically fix legacy storage ' . '"' . $oldId . '" => "' . $newId . '"' . ' because they both have data.');
         }
         if ($row1 === false || (int) $row1['storage'] === $oldNumericId) {
             // old storage has data, then delete the empty new id
             $toDelete = $newId;
         } else {
             if ((int) $row1['storage'] === $newNumericId) {
                 // new storage has data, then delete the empty old id
                 $toDelete = $oldId;
             } else {
                 // unknown case, do not continue
                 return false;
             }
         }
         // delete storage including file cache
         Storage::remove($toDelete);
         // if we deleted the old id, the new id will be used
         // automatically
         if ($toDelete === $oldId) {
             // nothing more to do
             return true;
         }
     }
     // rename old id to new id
     $newId = Storage::adjustStorageId($newId);
     $oldId = Storage::adjustStorageId($oldId);
     $rowCount = $this->renameStorageStatement->execute(array($newId, $oldId));
     $this->renameStorageStatement->closeCursor();
     return $rowCount === 1;
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:62,代码来源:RepairLegacyStorages.php

示例3: updateLegacyId

 /**
  * Updates old storage ids (v0.2.1 and older) that are based on key and secret to new ones based on the bucket name.
  * TODO Do this in an update.php. requires iterating over all users and loading the mount.json from their home
  *
  * @param array $params
  */
 public function updateLegacyId(array $params)
 {
     $oldId = 'amazon::' . $params['key'] . md5($params['secret']);
     // find by old id or bucket
     $stmt = \OC::$server->getDatabaseConnection()->prepare('SELECT `numeric_id`, `id` FROM `*PREFIX*storages` WHERE `id` IN (?, ?)');
     $stmt->execute(array($oldId, $this->id));
     while ($row = $stmt->fetch()) {
         $storages[$row['id']] = $row['numeric_id'];
     }
     if (isset($storages[$this->id]) && isset($storages[$oldId])) {
         // if both ids exist, delete the old storage and corresponding filecache entries
         \OC\Files\Cache\Storage::remove($oldId);
     } else {
         if (isset($storages[$oldId])) {
             // if only the old id exists do an update
             $stmt = \OC::$server->getDatabaseConnection()->prepare('UPDATE `*PREFIX*storages` SET `id` = ? WHERE `id` = ?');
             $stmt->execute(array($this->id, $oldId));
         }
     }
     // only the bucket based id may exist, do nothing
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:27,代码来源:amazons3.php

示例4: delete

 /**
  * Delete the user
  *
  * @return bool
  */
 public function delete()
 {
     if ($this->emitter) {
         $this->emitter->emit('\\OC\\User', 'preDelete', array($this));
     }
     $result = $this->backend->deleteUser($this->uid);
     if ($result) {
         // FIXME: Feels like an hack - suggestions?
         // We have to delete the user from all groups
         foreach (\OC_Group::getUserGroups($this->uid) as $i) {
             \OC_Group::removeFromGroup($this->uid, $i);
         }
         // Delete the user's keys in preferences
         \OC::$server->getConfig()->deleteAllUserValues($this->uid);
         // Delete user files in /data/
         \OC_Helper::rmdirr(\OC_User::getHome($this->uid));
         // Delete the users entry in the storage table
         \OC\Files\Cache\Storage::remove('home::' . $this->uid);
         \OC::$server->getCommentsManager()->deleteReferencesOfActor('users', $this->uid);
         \OC::$server->getCommentsManager()->deleteReadMarksFromUser($this);
     }
     if ($this->emitter) {
         $this->emitter->emit('\\OC\\User', 'postDelete', array($this));
     }
     return !($result === false);
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:31,代码来源:User.php

示例5: deleteUser

 /**
  * @brief delete a user
  * @param string $uid The username of the user to delete
  * @return bool
  *
  * Deletes a user
  */
 public static function deleteUser($uid)
 {
     $user = self::getManager()->get($uid);
     if ($user) {
         $result = $user->delete();
         // if delete was successful we clean-up the rest
         if ($result) {
             // We have to delete the user from all groups
             foreach (OC_Group::getUserGroups($uid) as $i) {
                 OC_Group::removeFromGroup($uid, $i);
             }
             // Delete the user's keys in preferences
             OC_Preferences::deleteUser($uid);
             // Delete user files in /data/
             $home = \OC_User::getHome($uid);
             OC_Helper::rmdirr($home);
             // Delete the users entry in the storage table
             \OC\Files\Cache\Storage::remove('home::' . $uid);
             \OC\Files\Cache\Storage::remove('local::' . $home . '/');
             // Remove it from the Cache
             self::getManager()->delete($uid);
         }
         return true;
     } else {
         return false;
     }
 }
开发者ID:hjimmy,项目名称:owncloud,代码行数:34,代码来源:user.php


注:本文中的OC\Files\Cache\Storage::remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。