Changeset View
Changeset View
Standalone View
Standalone View
lib/ext/Syncroton/Command/FolderCreate.php
Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | public function handle() | ||||
if (!$this->_folder) { | if (!$this->_folder) { | ||||
$this->_status = Syncroton_Command_FolderSync::STATUS_UNKNOWN_ERROR; | $this->_status = Syncroton_Command_FolderSync::STATUS_UNKNOWN_ERROR; | ||||
} else { | } else { | ||||
$this->_folder->class = $folder->class; | $this->_folder->class = $folder->class; | ||||
$this->_folder->deviceId = $this->_device; | $this->_folder->deviceId = $this->_device; | ||||
$this->_folder->creationTime = $this->_syncTimeStamp; | $this->_folder->creationTime = $this->_syncTimeStamp; | ||||
// Check if the folder already exists to avoid a duplicate insert attempt in db | |||||
try { | |||||
$this->_folderBackend->getFolder($this->_device, $this->_folder->serverId); | |||||
if ($this->_logger instanceof Zend_Log) | |||||
$this->_logger->info(__METHOD__ . '::' . __LINE__ . " Attempted to create a folder that already exists. parentId: {$folder->parentId} displayName: {$folder->displayName}"); | |||||
// The folder already exists | |||||
$this->_status = Syncroton_Command_FolderSync::STATUS_FOLDER_EXISTS; | |||||
} catch (Syncroton_Exception_NotFound $e) { | |||||
// This is the normal case | |||||
if ($this->_logger instanceof Zend_Log) | |||||
$this->_logger->debug(__METHOD__ . '::' . __LINE__ . " " . $e->getMessage()); | |||||
$this->_folderBackend->create($this->_folder); | $this->_folderBackend->create($this->_folder); | ||||
} | } | ||||
} | |||||
} catch (Syncroton_Exception_Status $e) { | } catch (Syncroton_Exception_Status $e) { | ||||
if ($this->_logger instanceof Zend_Log) | if ($this->_logger instanceof Zend_Log) | ||||
$this->_logger->debug(__METHOD__ . '::' . __LINE__ . " " . $e->getMessage()); | $this->_logger->info(__METHOD__ . '::' . __LINE__ . " " . $e->getMessage()); | ||||
$this->_status = $e->getCode(); | $this->_status = $e->getCode(); | ||||
} catch (Exception $e) { | } catch (Exception $e) { | ||||
if ($this->_logger instanceof Zend_Log) | if ($this->_logger instanceof Zend_Log) | ||||
$this->_logger->debug(__METHOD__ . '::' . __LINE__ . " " . $e->getMessage()); | $this->_logger->warn(__METHOD__ . '::' . __LINE__ . " " . $e->getMessage()); | ||||
$this->_status = Syncroton_Command_FolderSync::STATUS_UNKNOWN_ERROR; | $this->_status = Syncroton_Command_FolderSync::STATUS_UNKNOWN_ERROR; | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* generate FolderCreate response | * generate FolderCreate response | ||||
*/ | */ | ||||
Show All 22 Lines |