GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/upload_local.h
Date: 2024-04-28 02:33:07
Exec Total Coverage
Lines: 4 5 80.0%
Branches: 1 4 25.0%

Line Branch Exec Source
1 /**
2 * This file is part of the CernVM File System.
3 */
4
5 #ifndef CVMFS_UPLOAD_LOCAL_H_
6 #define CVMFS_UPLOAD_LOCAL_H_
7
8 #include <sys/stat.h>
9 #include <unistd.h>
10
11 #include <string>
12
13 #include "upload_facility.h"
14 #include "util/atomic.h"
15 #include "util/concurrency.h"
16
17 namespace upload {
18
19 struct LocalStreamHandle : public UploadStreamHandle {
20 147 LocalStreamHandle(const CallbackTN *commit_callback, const int tmp_fd,
21 const std::string &tmp_path)
22 147 : UploadStreamHandle(commit_callback),
23 147 file_descriptor(tmp_fd),
24
1/2
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
147 temporary_path(tmp_path) {}
25
26 const int file_descriptor;
27 const std::string temporary_path;
28 };
29
30 /**
31 * The LocalSpooler implements the AbstractSpooler interface to push files
32 * into a local CVMFS repository backend.
33 * For a detailed description of the classes interface please have a look into
34 * the AbstractSpooler base class.
35 */
36 class LocalUploader : public AbstractUploader {
37 private:
38 static const mode_t default_backend_file_mode_ = 0666;
39 static const mode_t default_backend_dir_mode_ = 0777;
40 const mode_t backend_file_mode_;
41 const mode_t backend_dir_mode_;
42
43 public:
44 explicit LocalUploader(const SpoolerDefinition &spooler_definition);
45 static bool WillHandle(const SpoolerDefinition &spooler_definition);
46
47 virtual std::string name() const { return "Local"; }
48
49 virtual bool Create();
50
51 /**
52 * Upload() is not done concurrently in the current implementation of the
53 * LocalSpooler, since it is a simple move or copy of a file without CPU
54 * intensive operation
55 * This method calls NotifyListeners and invokes a callback for all
56 * registered listeners (see the Observable template for details).
57 */
58 void DoUpload(const std::string &remote_path,
59 IngestionSource *source,
60 const CallbackTN *callback);
61
62 UploadStreamHandle *InitStreamedUpload(const CallbackTN *callback);
63 void StreamedUpload(UploadStreamHandle *handle, UploadBuffer buffer,
64 const CallbackTN *callback = NULL);
65 void FinalizeStreamedUpload(UploadStreamHandle *handle,
66 const shash::Any &content_hash);
67
68 void DoRemoveAsync(const std::string &file_to_delete);
69
70 bool Peek(const std::string &path);
71
72 bool Mkdir(const std::string &path);
73
74 bool PlaceBootstrappingShortcut(const shash::Any &object);
75
76 /**
77 * Determines the number of failed jobs in the LocalCompressionWorker as
78 * well as in the Upload() command.
79 */
80 unsigned int GetNumberOfErrors() const;
81
82 int64_t DoGetObjectSize(const std::string &file_name);
83
84 protected:
85 int Move(const std::string &local_path, const std::string &remote_path) const;
86
87 private:
88 // state information
89 const std::string upstream_path_;
90 const std::string temporary_path_;
91 mutable atomic_int32 copy_errors_; //!< counts the number of occurred
92 //!< errors in Upload()
93 };
94
95 } // namespace upload
96
97 #endif // CVMFS_UPLOAD_LOCAL_H_
98