Skip to content

Trouble persisting to file a file or directory upload to file share #288

@SMTOLL

Description

@SMTOLL

Which service(blob, file) does this issue concern?

File

Which version of the SDK was used?

2.04

On which platform were you using? (.Net Framework version or .Net Core version, and OS version)

.Net Framework

How can the problem be reproduced? It'd be better if the code caused the problem can be shared.

Retrieving the initial checkpoint from context:
TransferCheckpoint checkpoint = context.LastCheckpoint;

Serializing checkpoint to file:

IFormatter formatter = new BinaryFormatter();
using (FileStream fileStream = new FileStream(serializedCheckpointFilePath, FileMode.Create, FileAccess.Write, FileShare.None))
                formatter.Serialize(fileStream, checkpoint);

Deserializing checkpoint from file:

IFormatter formatter = new BinaryFormatter();
TransferCheckpoint deserializedCheckpoint;
using (FileStream fileStream = new FileStream(serializedCheckpointFilePath, FileMode.Open, FileAccess.Read, FileShare.None))
                deserializedCheckpoint = formatter.Deserialize(fileStream) as TransferCheckpoint;

Getting context and setting the bytes progress tracker:
Note: GetSingleTransferContext is GetDirectoryTransferContext if uploading directory

Progress<TransferStatus> p = new Progress<TransferStatus>();
p.ProgressChanged += ( sender,  status) => Console.WriteLine($"Bytes Transferred: {status.BytesTransferred}");
context = GetSingleTransferContext(checkpoint, p);

Using either TransferManager Upload Method:
Task UploadAsync(string sourcePath,CloudFile destFile, UploadOptions options, SingleTransferContext context, CancellationToken cancellationToken) (upload options: null)
Task<TransferStatus> UploadDirectoryAsync(string sourcePath,CloudFileDirectory destFileDir,UploadDirectoryOptions options, DirectoryTransferContext context, CancellationToken cancellationToken) (upload directory options: recursive set to true)

What problem was encountered?

I have been trying to separately persist to file the states of both a file and directory upload to file share. Using samples/DataMovementSamples/DataMovementSamples/Samples.cs as a guide, I capture the last checkpoint, serialize it to file, deserialize it, then use it in the respective upload function. However, the upload itself does not appear to resume where it left off. Instead, it seems to start over every time. Interestingly, the running BytesTransferred does appear to be persisted, as that number picks up where it left off. By the end of the upload, the final BytesTransferred is intialBytesUploaded + size of the file/directory.
When I used the same process without serialization (just taking the checkpoint, reconstructing the context, and uploading), everything worked as expected (BytesTransferred = size of the file/directory).

My guesses are that I am either doing something wrong with the serialization, not setting an option somewhere before or after the persistence, or that this is not even possible. No matter the case, any help that can be provided is much appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions