internal bool ResumeUpload()

in AdlsDotNetSDK/FileTransfer/FileMetaData.cs [201:251]


        internal bool ResumeUpload(AdlsClient client)
        {
            lock (_lock)
            {
                if (_shouldFileBeResumed != null)
                {
                    return _shouldFileBeResumed.Value;
                }
                bool chunkTempDestExists = client.CheckExists(ChunkSegmentFolder);
                bool chunkConcatTempDestExists =
                    client.CheckExists(ChunkSegmentFolder + FileUploader.DestTempGuidForConcat);
                _shouldFileBeResumed = false;
                // Chunks of a file will be resumed only if the chunksegment folder exists and the temp destination guid does not exist and all chunks were not reported to be done
                if (chunkTempDestExists)
                {
                    if (chunkConcatTempDestExists)
                    {
                        // BOOM throw exception because both cant exist- probably problem with concat
                        UnexpectedTransferErrorResume = $"{SrcFile}: Irrecoverable error, Concat is in an intermediate state. Please trasnfer this file without resume flag.";
                    }
                    else if (StartChunksAlreadyTransfered == TotalChunks)
                    {
                        // Add full concat job and you are done
                        Transfer.AddConcatJobToQueue(SrcFile, ChunkSegmentFolder, Dest, TotSize, TotalChunks);
                    }
                    else
                    {
                        // Continue with the job
                        _shouldFileBeResumed = true;
                    }

                }
                else if (chunkConcatTempDestExists)
                {
                    // We only need to add rename part of the concat job
                    Transfer.AddConcatJobToQueue(SrcFile, ChunkSegmentFolder, Dest, TotSize, TotalChunks, true);
                }
                else if (!client.CheckExists(Dest))
                {
                    // At this stage dest has to exist
                    // Again something really wrong happened- probably the rename failed even after retries with some intermediate state
                    UnexpectedTransferErrorResume = $"{SrcFile}: Irrecoverable error, Rename is in an intermediate state. Please trasnfer this file without resume flag.";
                }
                else
                {
                    // All chunks are transferred and the rename happened successfully, put in  record so that we do not have to do these checks again for the file
                    Transfer.AddCompleteRecord(SrcFile,true);
                }
                return _shouldFileBeResumed.Value;
            }
        }