Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

SSH/SftpChannel Problem?



  • when I calls the sftpchannel's listDirectory function Twice ,the program just calls one ,what's the problem?


  • Moderators

    @HAILINLU
    in order to expect decent help you should be more specific than this...



  • there are two functions :cd function used to collect the operation Command and list function used to calls the listDirectory function in the sftpchannel class ,but when I exec the cd function twice ,the list just exec one time.when the last Command finished ,I will calls the execCmdList function to continue the operation.
    void ZSftpOperation::execCmdList()
    {
    if(m_commandQueue.isEmpty())
    {
    return;
    }

    Command cmd = m_commandQueue.dequeue();
    
    switch (cmd) {
    case Cd:
        if(m_cdFile.isEmpty())
        {
            return;
        }
        else
        {
            QString remoteDir = m_cdFile.dequeue();
            list(remoteDir);
        }
        break;
    case Download:
        if(m_downloadFile.isEmpty())
        {
            return;
        }
        else
        {
            QPair<QString,QPair<QString,QString> > downMap;
            QPair<QString,QString> downPair;
            QString remoteFileName;
            QString localPath;
            downMap = m_downloadFile.dequeue();
            //m_remoteDir = downMap.first;
            downPair = downMap.second;
            remoteFileName = downPair.first;
            localPath = downPair.second;
            download(remoteFileName,localPath);
        }
        break;
    case Upload:
        if(m_uploadFile.isEmpty())
        {
            return;
        }
        else
        {
            QPair<QString,QPair<QString,QString> > upMap;
            QPair<QString,QString> upPair;
            QString remoteFileName;
            QString localPath;
            upMap = m_uploadFile.dequeue();
            //m_remoteDir = upMap.first;
            upPair = upMap.second;
            localPath = upPair.first;
            remoteFileName = upPair.second;
            upload(localPath,remoteFileName);
        }
        break;
    case Close:
        closeSFTPChannel();
        break;
    default:
        break;
    }
    

    }

    void ZSftpOperation::cd(const QString &remoteDir)
    {
    m_commandQueue.enqueue(Cd);
    m_cdFile.enqueue(remoteDir);
    if(isDone)
    {
    //execCmdList();
    }
    else
    {
    emit done(isDone);
    }
    }

    void ZSftpOperation::list(const QString &remoteDir)
    {
    m_jobType = JobListDir;
    m_currentCmd = Cd;
    m_remoteDir = remoteDir;
    m_jobListDirId = m_channel->listDirectory(m_remoteDir);
    isDone = false;
    emit done(isDone);
    }



  • I have resolved the problem! It's my operation error,I begin another operation before the last operation finished.


Log in to reply