Search code examples
synchronizationvirtualfilesystemvirtual-drive

How to overcome 4Gb limitation on file download in virtual drive based on Cloud Sync Engine?


I am implementing a virtual drive using Cloud Files API and this project. However, the download is stuck on files larger than 4Gb. The progress stops and the TransferDataAsync() is never called again, even though there are more bytes left in the file.


Solution

  • You need to add optional length to the segment length:

    public async Task TransferDataAsync(long offset, long length,
        ITransferDataOperationContext operationContext, ITransferDataResultContext resultContext)
    {
        if (operationContext.FileSize > 0x100000000)
        {
            length += operationContext.OptionalLength;
        }
        …
    }
    

    From my experience, this will somewhat slow down the download for small files. So it makes sense to do this only for files over 4Gb.