#include <FileDownloader.h>

Inheritance diagram for giga::core::FileDownloader:
giga::core::FileTransferer

Classes

struct  Result
 

Public Types

enum  Policy { Policy::override, Policy::overrideNewerSize, Policy::ignore, Policy::rename }
 
enum  Action { fileOverriden, fileIgnored, fileRenamed, fileDownloaded }
 
- Public Types inherited from giga::core::FileTransferer
enum  State {
  pending, started, paused, canceled,
  error
}
 

Public Member Functions

 FileDownloader (const boost::filesystem::path &folderDest, const Node &node, const Application &app, pplx::cancellation_token_source cts=pplx::cancellation_token_source{}, Policy policy=Policy::ignore)
 Construct a FileDownloader. More...
 
 FileDownloader (FileDownloader &&other)
 
 FileDownloader (const FileDownloader &)=delete
 
FileDownloaderoperator= (const FileDownloader &)=delete
 
FileDownloaderoperator= (FileDownloader &&)=delete
 
const pplx::task< Result > & task () const
 Gets the task managing the download. Make sure it has been started first (see FileTransferer::start()) More...
 
const boost::filesystem::path & downloadingFile () const
 
const boost::filesystem::path & destinationFile () const
 
FileTransferer::Progress progress () const override
 
const boost::filesystem::path & filename () const override
 
- Public Member Functions inherited from giga::core::FileTransferer
 FileTransferer (pplx::cancellation_token_source cts)
 
 FileTransferer (FileTransferer &&other)
 
 FileTransferer (const FileTransferer &)=delete
 
FileTransfereroperator= (const FileTransferer &)=delete
 
FileTransfereroperator= (FileTransferer &&)=delete
 
void start ()
 Start a transfer.
 
void pause ()
 Pause the current transfer (see resume())
 
void resume ()
 Resume the current transfer (see pause())
 
void cancel ()
 Cancel a started upload. The task managing the transfer will most probably throw an exception.
 
void setError (const std::string &error)
 
State state () const
 
void limitRate (uint64_t rate)
 Limit the rate of the transfer. More...
 

Protected Member Functions

void doStart () override
 

Additional Inherited Members

- Protected Attributes inherited from giga::core::FileTransferer
State _state
 
std::unique_ptr
< details::CurlProgress
_progress
 
std::mutex _mut
 
pplx::cancellation_token_source _cts
 
utility::string_t _error
 

Detailed Description

Download a file

Member Enumeration Documentation

Enumerator
override 

If a file with the same name is found, override it.

overrideNewerSize 

Override a file with the same name if:

  • its size is different from the downloading one
  • or its last modification date is older than the downloading one

Else ignore the file (no download).

ignore 

Do not download files that already exists.

rename 

Rename the downloading file if needed to avoid collision.

Constructor & Destructor Documentation

giga::core::FileDownloader::FileDownloader ( const boost::filesystem::path &  folderDest,
const Node node,
const Application app,
pplx::cancellation_token_source  cts = pplx::cancellation_token_source{},
Policy  policy = Policy::ignore 
)
explicit

Construct a FileDownloader.

Parameters
folderDestthe folder in which we want to put the downloaded node
nodethe node to download
appthe authenticated application
ctsa cancel token to use for canceling the download task
policywhat to do if a file with the same name already exists

Member Function Documentation

const path & giga::core::FileDownloader::destinationFile ( ) const

At the end of the download process, the file will be here

const path & giga::core::FileDownloader::downloadingFile ( ) const

During the download process, we use this temporary file

const pplx::task< FileDownloader::Result > & giga::core::FileDownloader::task ( ) const

The documentation for this class was generated from the following files:
  • /home/thomas/code/GiGaSdk/src/giga/core/FileDownloader.h
  • /home/thomas/code/GiGaSdk/src/giga/core/FileDownloader.cpp