Skip to content

Change to resume incomplete download, even if the application is closed. #17

@jorensanbar

Description

@jorensanbar
  • I can't push this changes, so...

Small change that allows you to resume a download, even after the application has been completely closed.

//Get the download headers if not exists
                if (Info == null)
                {
                    State = Status.GettingHeaders;
                    GetHeaders();
                    aop.Post(delegate { DownloadInfoReceived.Raise(this, EventArgs.Empty); }, null);
                    Thread.Sleep(500); //Required to wait for the DownloadInfoReceived event to finish.
                }

//Get the Bytes Received before start download, and check if the file on disk is incomplete
                FileInfo fileInfo = new FileInfo(FullFileName);

                if (fileInfo.Exists)
                    if (fileInfo.Length <= Info.Length)
                        TotalBytesReceived = fileInfo.Length;

imagen

In FileHelper Class, you can append file without checksum

if (!string.IsNullOrEmpty(lastChecksum))
                {
                    var currentChecksum = CalculateMD5(filePath);
                    if (currentChecksum != lastChecksum)
                        throw new FileValidationFailedException(filePath, lastChecksum, currentChecksum);
                    else return new FileStream(filePath, FileMode.Append, FileAccess.Write);
                }
                else return new FileStream(filePath, FileMode.Append, FileAccess.Write);

imagen

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions