CernVM-FS  2.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
upload_local.h
Go to the documentation of this file.
1 
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 "atomic.h"
14 #include "upload_facility.h"
15 #include "util_concurrency.h"
16 
17 namespace upload {
18 
20  LocalStreamHandle(const CallbackTN *commit_callback, const int tmp_fd,
21  const std::string &tmp_path)
22  : UploadStreamHandle(commit_callback),
23  file_descriptor(tmp_fd),
24  temporary_path(tmp_path) {}
25 
26  const int file_descriptor;
27  const std::string temporary_path;
28 };
29 
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:
46 
47  virtual std::string name() const { return "Local"; }
48 
49  virtual bool Create();
50 
58  void DoUpload(const std::string &remote_path,
59  IngestionSource *source,
60  const CallbackTN *callback = NULL);
61 
62  UploadStreamHandle *InitStreamedUpload(const CallbackTN *callback = NULL);
63  void StreamedUpload(UploadStreamHandle *handle, UploadBuffer buffer,
64  const CallbackTN *callback = NULL);
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 
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_;
92 };
94 
95 } // namespace upload
96 
97 #endif // CVMFS_UPLOAD_LOCAL_H_
const std::string upstream_path_
Definition: upload_local.h:89
virtual bool Create()
Definition: upload_local.cc:39
LocalUploader(const SpoolerDefinition &spooler_definition)
Definition: upload_local.cc:18
UploadStreamHandle * InitStreamedUpload(const CallbackTN *callback=NULL)
bool Peek(const std::string &path)
const std::string temporary_path_
Definition: upload_local.h:90
const SpoolerDefinition & spooler_definition() const
void StreamedUpload(UploadStreamHandle *handle, UploadBuffer buffer, const CallbackTN *callback=NULL)
void FinalizeStreamedUpload(UploadStreamHandle *handle, const shash::Any &content_hash)
virtual std::string name() const
Definition: upload_local.h:47
static const mode_t default_backend_file_mode_
Definition: upload_local.h:38
LocalStreamHandle(const CallbackTN *commit_callback, const int tmp_fd, const std::string &tmp_path)
Definition: upload_local.h:20
int32_t atomic_int32
Definition: atomic.h:17
void DoUpload(const std::string &remote_path, IngestionSource *source, const CallbackTN *callback=NULL)
Definition: upload_local.cc:44
const CallbackTN * commit_callback
unsigned int GetNumberOfErrors() const
Definition: upload_local.cc:35
int Move(const std::string &local_path, const std::string &remote_path) const
bool Mkdir(const std::string &path)
static const mode_t default_backend_dir_mode_
Definition: upload_local.h:39
const std::string temporary_path
Definition: upload_local.h:27
const mode_t backend_file_mode_
Definition: upload_local.h:40
int64_t DoGetObjectSize(const std::string &file_name)
bool PlaceBootstrappingShortcut(const shash::Any &object)
AbstractUploader::CallbackTN CallbackTN
void DoRemoveAsync(const std::string &file_to_delete)
const mode_t backend_dir_mode_
Definition: upload_local.h:41
atomic_int32 copy_errors_
Definition: upload_local.h:91
CallbackBase< UploaderResults > CallbackTN
Definition: async.h:192
static bool WillHandle(const SpoolerDefinition &spooler_definition)
Definition: upload_local.cc:31