GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/ingestion/task_write.cc
Date: 2024-04-21 02:33:16
Exec Total Coverage
Lines: 34 38 89.5%
Branches: 21 35 60.0%

Line Branch Exec Source
1 /**
2 * This file is part of the CernVM File System.
3 */
4
5 #include "cvmfs_config.h"
6 #include "task_write.h"
7
8 #include <cstdlib>
9
10 #include "upload_facility.h"
11 #include "util/exception.h"
12 #include "util/logging.h"
13
14
15 418870 void TaskWrite::OnBlockComplete(
16 const upload::UploaderResults &results,
17 BlockItem *block_item)
18 {
19
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 418870 times.
418870 if (results.return_code != 0) {
20 PANIC(kLogStderr, "block upload failed (code: %d)", results.return_code);
21 }
22
23
1/2
✓ Branch 0 taken 418870 times.
✗ Branch 1 not taken.
418870 delete block_item;
24 418870 }
25
26
27 250522 void TaskWrite::OnChunkComplete(
28 const upload::UploaderResults &results,
29 ChunkItem *chunk_item)
30 {
31
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 250522 times.
250522 if (results.return_code != 0) {
32 PANIC(kLogStderr, "chunk upload failed (code: %d)", results.return_code);
33 }
34
35 250522 FileItem *file_item = chunk_item->file_item();
36
1/2
✓ Branch 4 taken 250522 times.
✗ Branch 5 not taken.
501044 file_item->RegisterChunk(FileChunk(*chunk_item->hash_ptr(),
37 250522 chunk_item->offset(),
38 chunk_item->size()));
39
1/2
✓ Branch 0 taken 250522 times.
✗ Branch 1 not taken.
250522 delete chunk_item;
40
41
2/2
✓ Branch 1 taken 250083 times.
✓ Branch 2 taken 439 times.
250522 if (file_item->IsProcessed()) {
42 250083 tubes_out_->DispatchAny(file_item);
43 }
44 250522 }
45
46
47 668660 void TaskWrite::Process(BlockItem *input_block) {
48 668660 ChunkItem *chunk_item = input_block->chunk_item();
49
50 668595 upload::UploadStreamHandle *handle = chunk_item->upload_handle();
51
2/2
✓ Branch 0 taken 250334 times.
✓ Branch 1 taken 418232 times.
668566 if (handle == NULL) {
52 // The closure passed here, is called by the AbstractUploader as soon as
53 // it successfully committed the complete chunk
54 751150 handle = uploader_->InitStreamedUpload(
55
2/4
✓ Branch 1 taken 250410 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 250406 times.
✗ Branch 5 not taken.
250334 upload::AbstractUploader::MakeClosure(
56 &TaskWrite::OnChunkComplete, this, chunk_item));
57
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 250406 times.
250406 assert(handle != NULL);
58 250406 chunk_item->set_upload_handle(handle);
59 }
60
61
2/3
✓ Branch 1 taken 418520 times.
✓ Branch 2 taken 250356 times.
✗ Branch 3 not taken.
668597 switch (input_block->type()) {
62 418520 case BlockItem::kBlockData:
63
1/2
✓ Branch 2 taken 418783 times.
✗ Branch 3 not taken.
418511 uploader_->ScheduleUpload(
64 handle,
65 upload::AbstractUploader::UploadBuffer(
66 418477 input_block->size(), input_block->data()),
67
1/2
✓ Branch 1 taken 418472 times.
✗ Branch 2 not taken.
418520 upload::AbstractUploader::MakeClosure(
68 &TaskWrite::OnBlockComplete, this, input_block));
69 418783 break;
70 250356 case BlockItem::kBlockStop:
71 // If there is a sole piece and a legacy bulk chunk, two times the same
72 // chunk is being uploaded. Well. It doesn't hurt.
73
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 250350 times.
250356 if (chunk_item->IsSolePiece()) {
74
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 chunk_item->MakeBulkChunk();
75 }
76
1/2
✓ Branch 2 taken 250441 times.
✗ Branch 3 not taken.
250351 uploader_->ScheduleCommit(handle, *chunk_item->hash_ptr());
77
1/2
✓ Branch 0 taken 250441 times.
✗ Branch 1 not taken.
250441 delete input_block;
78 250484 break;
79 default:
80 PANIC(NULL);
81 }
82 669267 }
83