RemoteFileRenameOperation::RemoteFileRenameOperation(FileInfo sourceFileInfo,
                                                     FileInfo targetFileInfo,
                                                     const TCHAR *pathToTargetRoot)
{
  FileInfoList srcList(sourceFileInfo);
  FileInfoList dstList(targetFileInfo);

  getRemotePath(&srcList, pathToTargetRoot, &m_pathToSourceFile);
  getRemotePath(&dstList, pathToTargetRoot, &m_pathToTargetFile);
}
void DownloadOperation::changeFileToDownload(FileInfoList *toDownload)
{
  m_toCopy = toDownload;

  getRemotePath(m_toCopy, m_pathToSourceRoot.getString(), &m_pathToSourceFile);
  getLocalPath(m_toCopy, m_pathToTargetRoot.getString(), &m_pathToTargetFile);
}
void RemoteFilesDeleteOperation::remove(bool removeIfFolder)
{
  if (isTerminating()) {
    killOp();
    return ;
  }

  if (m_toDelete == NULL) {
    return ;
  }

  FileInfo *fileInfo = m_toDelete->getFileInfo();

  StringStorage remotePath;

  getRemotePath(m_toDelete,
                m_pathToTargetRoot.getString(),
                &remotePath);

  //
  // Logging
  //

  if (((fileInfo->isDirectory() && !removeIfFolder) ||
      (!fileInfo->isDirectory())) && (m_toDelete->getFirst()->getParent() == NULL)) {
    StringStorage message;

    message.format(_T("Deleting remote '%s' %s"), remotePath.getString(),
                   fileInfo->isDirectory() ? _T("folder") : _T("file"));

    notifyInformation(message.getString());
  }

  //
  // Try remove file if it's not folder or have order to forced
  // file removal.
  //

  if (!fileInfo->isDirectory() || removeIfFolder) {
    // Send request to server
    m_sender->sendRmFileRequest(remotePath.getString());

    //
    // If file is folder and we have order to forced removal
    // we must set folder child to NULL. If we dont do than
    // program will try to remove already removed files next step.
    //

    if ((removeIfFolder) && (fileInfo->isDirectory())) {
      m_toDelete->setChild(NULL, 0);
    }
  } else {
    // Send file list request cause we must remove subfolders and files from
    // folder before we can delete it
    m_sender->sendFileListRequest(remotePath.getString(), m_replyBuffer->isCompressionSupported());
  }
}
RemoteFolderCreateOperation::RemoteFolderCreateOperation(LogWriter *logWriter,
                                                         FileInfo file,
                                                         const TCHAR *pathToTargetRoot)
: FileTransferOperation(logWriter)
{
  FileInfoList *list = new FileInfoList(file);
  getRemotePath(list, pathToTargetRoot, &m_pathToTargetFile);
  delete list;
}
void RemoteFilesDeleteOperation::onLastRequestFailedReply()
{
  //
  // Logging
  //

  StringStorage errorMessage;
  m_replyBuffer->getLastErrorMessage(&errorMessage);

  StringStorage remotePath;
  getRemotePath(m_toDelete, m_pathToTargetRoot.getString(), &remotePath);

  StringStorage message;
  message.format(_T("Error: %s ('%s')"), errorMessage.getString(),
                 remotePath.getString());

  notifyError(message.getString());

  // Delete next file
  gotoNext();
}
Beispiel #6
0
void UploadOperation::gotoNext(bool fake)
{
    FileInfoList *current = m_toCopy;

    bool hasChild = current->getChild() != NULL;
    bool hasNext = current->getNext() != NULL;
    bool hasParent = current->getFirst()->getParent() != NULL;

    if (hasChild) {
        if (fake) {
            m_gotoChild = true;

            m_sender->sendFileListRequest(m_pathToTargetFile.getString(),
                                          m_replyBuffer->isCompressionSupported());
            return ;
        } else {
            // If it has child, we must upload child file list first
            changeFileToUpload(current->getChild());
            startUpload();
        }
    } else if (hasNext) {
        // If it has no child, but has next file, we must upload next file
        changeFileToUpload(current->getNext());
        startUpload();
    } else {

        //
        // If it has no child and not next, but has parent file,
        // we must go to parent file (folder i mean), set childs to NULL
        // cause we already upload child files and go to next file.
        //

        FileInfoList *first = current->getFirst();
        if (hasParent) {
            if (fake) {
                m_gotoParent = true;

                StringStorage pathToRemoteFolder(m_pathToTargetRoot.getString());

                FileInfoList *parentOfCurrent = m_toCopy->getFirst()->getParent();
                FileInfoList *parentOfParent = NULL;

                if (parentOfCurrent != NULL) {
                    parentOfParent = parentOfCurrent->getFirst()->getParent();
                }

                if (parentOfParent != NULL) {
                    getRemotePath(parentOfParent, m_pathToTargetRoot.getString(), &pathToRemoteFolder);
                }

                m_sender->sendFileListRequest(pathToRemoteFolder.getString(),
                                              m_replyBuffer->isCompressionSupported());
                return ;
            } else {
                changeFileToUpload(first->getParent());
                m_toCopy->setChild(NULL, 0);
                gotoNext();
            }
        } else {
            killOp();
        } // if / else
    } // if / else
} // void