GCC Code Coverage Report
Directory: cvmfs/ Exec Total Coverage
File: cvmfs/upload_local.h Lines: 4 5 80.0 %
Date: 2019-02-03 02:48:13 Branches: 2 7 28.6 %

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
10
#include <string>
11
12
#include "atomic.h"
13
#include "upload_facility.h"
14
#include "util_concurrency.h"
15
16
namespace upload {
17
18
232
struct LocalStreamHandle : public UploadStreamHandle {
19
116
  LocalStreamHandle(const CallbackTN *commit_callback, const int tmp_fd,
20
                    const std::string &tmp_path)
21
      : UploadStreamHandle(commit_callback),
22
        file_descriptor(tmp_fd),
23
116
        temporary_path(tmp_path) {}
24
25
  const int file_descriptor;
26
  const std::string temporary_path;
27
};
28
29
/**
30
 * The LocalSpooler implements the AbstractSpooler interface to push files
31
 * into a local CVMFS repository backend.
32
 * For a detailed description of the classes interface please have a look into
33
 * the AbstractSpooler base class.
34
 */
35

64
class LocalUploader : public AbstractUploader {
36
 private:
37
  static const mode_t default_backend_file_mode_ = 0666;
38
  const mode_t backend_file_mode_;
39
40
 public:
41
  explicit LocalUploader(const SpoolerDefinition &spooler_definition);
42
  static bool WillHandle(const SpoolerDefinition &spooler_definition);
43
44
  virtual std::string name() const { return "Local"; }
45
46
  /**
47
   * Upload() is not done concurrently in the current implementation of the
48
   * LocalSpooler, since it is a simple move or copy of a file without CPU
49
   * intensive operation
50
   * This method calls NotifyListeners and invokes a callback for all
51
   * registered listeners (see the Observable template for details).
52
   */
53
  void FileUpload(const std::string &local_path, const std::string &remote_path,
54
                  const CallbackTN *callback = NULL);
55
56
  UploadStreamHandle *InitStreamedUpload(const CallbackTN *callback = NULL);
57
  void StreamedUpload(UploadStreamHandle *handle, UploadBuffer buffer,
58
                      const CallbackTN *callback = NULL);
59
  void FinalizeStreamedUpload(UploadStreamHandle *handle,
60
                              const shash::Any &content_hash);
61
62
  void DoRemoveAsync(const std::string &file_to_delete);
63
64
  bool Peek(const std::string &path) const;
65
66
  bool PlaceBootstrappingShortcut(const shash::Any &object) const;
67
68
  /**
69
   * Determines the number of failed jobs in the LocalCompressionWorker as
70
   * well as in the Upload() command.
71
   */
72
  unsigned int GetNumberOfErrors() const;
73
74
  int64_t DoGetObjectSize(const std::string &file_name);
75
76
 protected:
77
  int Move(const std::string &local_path, const std::string &remote_path) const;
78
79
 private:
80
  // state information
81
  const std::string upstream_path_;
82
  const std::string temporary_path_;
83
  mutable atomic_int32 copy_errors_;  //!< counts the number of occured
84
                                      //!< errors in Upload()
85
};
86
87
}  // namespace upload
88
89
#endif  // CVMFS_UPLOAD_LOCAL_H_