Results 1 to 20 of 30

Thread: How to check the file to download from ftp site exists ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to check the file to download from ftp site exists ?

    Quote Originally Posted by ChrisW67 View Post
    Only the first option is available using QNetworkAccessManager AFAICT, but you could abort() the download as soon as you see the metadataChanged() signal.
    There is QFtp::list() available (since OP is using QFtp anyway).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to check the file to download from ftp site exists ?

    There you go pointing the OP straight at it ... I was trying to be more subtle by saying that QFtp had functions for both and that some RTFM action might be needed.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to check the file to download from ftp site exists ?

    Ouch, sorry.. didn't read your post carefully enough... Still one has to read the docs to learn how to process the response QFtp receives.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: How to check the file to download from ftp site exists ?

    Quote Originally Posted by ChrisW67 View Post
    There you go pointing the OP straight at it ... I was trying to be more subtle by saying that QFtp had functions for both and that some RTFM action might be needed.
    Could you please expand OP and RTFM and please let me know how to interpret it. Thanks.


    Added after 5 minutes:


    While fetching the data I am using QFtp::get and if the operation returned 'error' true for QFtp::CommandFinished(int, bool error) then the rest of QFtp commands are not executing. Since all the ftp commands are asynchronous, if one of the command fails does the remaining rest following them aborts ?, because my program does not do anything if any one of the ftp command returns 'error'.
    Last edited by nikhilqt; 16th February 2012 at 21:24.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to check the file to download from ftp site exists ?

    Quote Originally Posted by nikhilqt View Post
    Could you please expand OP and RTFM and please let me know how to interpret it.
    OP is "original poster" (meaning you). RTFM is... well... STFW for it

    The Jargon File
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to check the file to download from ftp site exists ?

    Quote Originally Posted by nikhilqt View Post
    While fetching the data I am using QFtp::get and if the operation returned 'error' true for QFtp::CommandFinished(int, bool error) then the rest of QFtp commands are not executing. Since all the ftp commands are asynchronous, if one of the command fails does the remaining rest following them aborts ?, because my program does not do anything if any one of the ftp command returns 'error'.
    From the friendly manual for QFtp (you have read it, haven't you? )...
    If an error occurs during the execution of one of the commands in a sequence of commands, all the pending commands (i.e. scheduled, but not yet executed commands) are cleared and no signals are emitted for them.

  7. #7
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: How to check the file to download from ftp site exists ?

    Quote Originally Posted by ChrisW67 View Post
    From the friendly manual for QFtp (you have read it, haven't you? )...
    Oh! it is there in the documentation . I didn't see it hard enough. So now it creates a issue for me for even 'ls filename' command, because the remaining QFtp::get(...) requests would be lost since the former command fails if the file is not present.

  8. #8
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to check the file to download from ftp site exists ?

    Why? If the list command fails there is no file to download. If you a queuing several file list/get commands at once, don't.

    I expect the list command will not fail if the file does not exist: it should just return no directory entries. (I have not verified that)

  9. The following user says thank you to ChrisW67 for this useful post:

    nikhilqt (27th February 2012)

  10. #9
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: How to check the file to download from ftp site exists ?

    Quote Originally Posted by ChrisW67 View Post
    I expect the list command will not fail if the file does not exist: it should just return no directory entries. (I have not verified that)
    But my requirement is to check whether that specific file exists or not in that folder. I cannot achieve it using list command. So as you said I used 'ls filename'.

    Why? If the list command fails there is no file to download. If you a queuing several file list/get commands at once, don't.
    There are some 40-50 files I need to download and this number might increase as well. So I queue up the request of all the raw command('ls filename') for all the files.

    My approach was to check the error status of all the raw commands and then selectively call the QFtp::get method only for those files which exists. But here the checking queue is itself failing for me.

  11. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to check the file to download from ftp site exists ?

    Quote Originally Posted by nikhilqt View Post
    But my requirement is to check whether that specific file exists or not in that folder. I cannot achieve it using list command.
    Why not?


    There are some 40-50 files I need to download and this number might increase as well. So I queue up the request of all the raw command('ls filename') for all the files.
    Don't do that then. Store the file data elsewhere and push commands to the ftp client as you begin processing a particular entry.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. The following user says thank you to wysota for this useful post:

    nikhilqt (27th February 2012)

  13. #11
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: How to check the file to download from ftp site exists ?

    Thanks. I made it work. In the process, I observed one more situation, where the QFtp::Get command will be running and there won't be write to the file in the local file system. This happens quite a sometime after the download of some 20-30 files. Is this because ftp has timeout and the state is been disconnected ?

    If I close the application and start it again, then the downloading starts normally. Have anybody experienced this behavior ?
    Last edited by nikhilqt; 27th February 2012 at 20:09.

  14. #12
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: How to check the file to download from ftp site exists ?

    Guys, Any help regarding this. Is there any timeout for the QFtp::Get command. Or do i need to close the ftp connection after sometime and need to re-initiate it ? Please share me your thoughts on it. Thanks

  15. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to check the file to download from ftp site exists ?

    I think you are adressing the question in the wrong place. If you want to learn how FTP servers work, then learn about FTP. Qt has nothing to do with this. Your "issue" is stricly FTP related from the very beginning.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. How to check Primary key is Exists in Table ?
    By hohoanganh205 in forum Newbie
    Replies: 4
    Last Post: 28th December 2011, 07:54
  2. Replies: 2
    Last Post: 21st February 2011, 14:52
  3. Check if item exists into listwidget
    By hakermania in forum Qt Programming
    Replies: 1
    Last Post: 26th January 2011, 21:54
  4. Check if a table exists in a mysql database
    By graciano in forum Qt Programming
    Replies: 8
    Last Post: 5th November 2009, 02:44
  5. Check if window with certain title exists
    By devil in forum Qt Programming
    Replies: 5
    Last Post: 21st January 2009, 14:42

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.