Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
SMTOLL opened this issue Jan 19, 2022 · 0 comments
Open

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

SMTOLL opened this issue Jan 19, 2022 · 0 comments

Comments

@SMTOLL
Copy link

SMTOLL commented Jan 19, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant