* @param string $uid ID if the user for whom we want to delete the key
* @param string $keyId id of the key
*
- * @return boolean
+ * @return boolean False when the key could not be deleted
*/
public function deleteUserKey($uid, $keyId) {
$path = $this->constructUserKeyPath($keyId, $uid);
- return $this->view->unlink($path);
+ return !$this->view->file_exists($path) || $this->view->unlink($path);
}
/**
* @param string $path path to file
* @param string $keyId id of the key
*
- * @return boolean
+ * @return boolean False when the key could not be deleted
*/
public function deleteFileKey($path, $keyId) {
$keyDir = $this->getFileKeyDir($path);
- return $this->view->unlink($keyDir . $keyId);
+ return !$this->view->file_exists($keyDir . $keyId) || $this->view->unlink($keyDir . $keyId);
}
/**
* delete all file keys for a given file
*
* @param string $path to the file
- * @return boolean
+ * @return boolean False when the key could not be deleted
*/
public function deleteAllFileKeys($path) {
$keyDir = $this->getFileKeyDir($path);
- return $this->view->deleteAll(dirname($keyDir));
+ $path = dirname($keyDir);
+ return !$this->view->file_exists($path) || $this->view->deleteAll($path);
}
/**
*
* @param string $keyId id of the key
*
- * @return boolean
+ * @return boolean False when the key could not be deleted
*/
public function deleteSystemUserKey($keyId) {
$path = $this->constructUserKeyPath($keyId);
- return $this->view->unlink($path);
+ return !$this->view->file_exists($path) || $this->view->unlink($path);
}
* @param string $uid ID if the user for whom we want to delete the key
* @param string $keyId id of the key
*
- * @return boolean
+ * @return boolean False when the key could not be deleted
*/
public function deleteUserKey($uid, $keyId);
* @param string $path path to file
* @param string $keyId id of the key
*
- * @return boolean
+ * @return boolean False when the key could not be deleted
*/
public function deleteFileKey($path, $keyId);
* delete all file keys for a given file
*
* @param string $path to the file
- * @return boolean
+ * @return boolean False when the keys could not be deleted
*/
public function deleteAllFileKeys($path);
*
* @param string $keyId id of the key
*
- * @return boolean
+ * @return boolean False when the key could not be deleted
*/
public function deleteSystemUserKey($keyId);
}
public function testDeleteUserKey() {
+ $this->view->expects($this->once())
+ ->method('file_exists')
+ ->with($this->equalTo('/user1/files_encryption/encModule/user1.publicKey'))
+ ->willReturn(true);
$this->view->expects($this->once())
->method('unlink')
->with($this->equalTo('/user1/files_encryption/encModule/user1.publicKey'))
}
public function testDeleteSystemUserKey() {
+ $this->view->expects($this->once())
+ ->method('file_exists')
+ ->with($this->equalTo('/files_encryption/encModule/shareKey_56884'))
+ ->willReturn(true);
$this->view->expects($this->once())
->method('unlink')
->with($this->equalTo('/files_encryption/encModule/shareKey_56884'))
$this->util->expects($this->any())
->method('isSystemWideMountPoint')
->willReturn(true);
+ $this->view->expects($this->once())
+ ->method('file_exists')
+ ->with($this->equalTo('/files_encryption/keys/files/foo.txt/encModule/fileKey'))
+ ->willReturn(true);
$this->view->expects($this->once())
->method('unlink')
->with($this->equalTo('/files_encryption/keys/files/foo.txt/encModule/fileKey'))
$this->util->expects($this->any())
->method('isSystemWideMountPoint')
->willReturn(false);
+ $this->view->expects($this->once())
+ ->method('file_exists')
+ ->with($this->equalTo('/user1/files_encryption/keys/files/foo.txt/encModule/fileKey'))
+ ->willReturn(true);
$this->view->expects($this->once())
->method('unlink')
->with($this->equalTo('/user1/files_encryption/keys/files/foo.txt/encModule/fileKey'))