GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/upload_spooler_definition.cc
Date: 2025-06-22 02:36:02
Exec Total Coverage
Lines: 32 44 72.7%
Branches: 18 35 51.4%

Line Branch Exec Source
1 /**
2 * This file is part of the CernVM File System.
3 */
4
5 #include "upload_spooler_definition.h"
6
7 #include <vector>
8
9 #include "util/logging.h"
10 #include "util/string.h"
11
12 namespace upload {
13
14 const char *SpoolerDefinition::kDriverNames[] = {"S3", "local", "gw", "mock",
15 "unknown"};
16
17 2752 SpoolerDefinition::SpoolerDefinition(
18 const std::string &definition_string,
19 const shash::Algorithms hash_algorithm,
20 const zlib::Algorithms compression_algorithm,
21 const bool generate_legacy_bulk_chunks,
22 const bool use_file_chunking,
23 const size_t min_file_chunk_size,
24 const size_t avg_file_chunk_size,
25 const size_t max_file_chunk_size,
26 const std::string &session_token_file,
27 2752 const std::string &key_file)
28 2752 : driver_type(Unknown)
29 2752 , hash_algorithm(hash_algorithm)
30 2752 , compression_alg(compression_algorithm)
31 2752 , generate_legacy_bulk_chunks(generate_legacy_bulk_chunks)
32 2752 , use_file_chunking(use_file_chunking)
33 2752 , min_file_chunk_size(min_file_chunk_size)
34 2752 , avg_file_chunk_size(avg_file_chunk_size)
35 2752 , max_file_chunk_size(max_file_chunk_size)
36 2752 , number_of_concurrent_uploads(kDefaultMaxConcurrentUploads)
37 2752 , num_upload_tasks(kDefaultNumUploadTasks)
38
1/2
✓ Branch 1 taken 2752 times.
✗ Branch 2 not taken.
2752 , session_token_file(session_token_file)
39
1/2
✓ Branch 1 taken 2752 times.
✗ Branch 2 not taken.
2752 , key_file(key_file)
40 2752 , valid_(false) {
41 // check if given file chunking values are sane
42
2/2
✓ Branch 0 taken 2705 times.
✓ Branch 1 taken 47 times.
2752 if (use_file_chunking
43
1/2
✓ Branch 0 taken 2705 times.
✗ Branch 1 not taken.
2705 && (min_file_chunk_size >= avg_file_chunk_size
44
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2705 times.
2705 || avg_file_chunk_size >= max_file_chunk_size)) {
45 LogCvmfs(kLogSpooler, kLogStderr, "file chunk size values are not sane");
46 return;
47 }
48
49 // split the spooler driver definition into name and config part
50
1/2
✓ Branch 1 taken 2752 times.
✗ Branch 2 not taken.
2752 std::vector<std::string> upstream = SplitString(definition_string, ',');
51
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2752 times.
2752 if (upstream.size() != 3) {
52 LogCvmfs(kLogSpooler, kLogStderr, "Invalid spooler driver");
53 return;
54 }
55
56 // recognize and configure the spooler driver
57
2/2
✓ Branch 2 taken 1635 times.
✓ Branch 3 taken 1117 times.
2752 if (upstream[0] == "local") {
58 1635 driver_type = Local;
59
2/2
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 949 times.
1117 } else if (upstream[0] == "S3") {
60 168 driver_type = S3;
61
2/2
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 902 times.
949 } else if (upstream[0] == "gw") {
62 47 driver_type = Gateway;
63
1/2
✓ Branch 2 taken 902 times.
✗ Branch 3 not taken.
902 } else if (upstream[0] == "mock") {
64 902 driver_type = Mock; // for unit testing purpose only!
65 } else {
66 driver_type = Unknown;
67 LogCvmfs(kLogSpooler, kLogStderr, "unknown spooler driver: %s",
68 upstream[0].c_str());
69 return;
70 }
71
72 // save data
73
1/2
✓ Branch 2 taken 2752 times.
✗ Branch 3 not taken.
2752 temporary_path = upstream[1];
74
1/2
✓ Branch 2 taken 2752 times.
✗ Branch 3 not taken.
2752 spooler_configuration = upstream[2];
75 2752 valid_ = true;
76
1/2
✓ Branch 1 taken 2752 times.
✗ Branch 2 not taken.
2752 }
77
78 SpoolerDefinition SpoolerDefinition::Dup2DefaultCompression() const {
79 SpoolerDefinition result(*this);
80 result.compression_alg = zlib::kZlibDefault;
81 return result;
82 }
83
84 } // namespace upload
85