1 |
|
|
/** |
2 |
|
|
* This file is part of the CernVM File System |
3 |
|
|
*/ |
4 |
|
|
|
5 |
|
|
#ifndef CVMFS_SYNC_ITEM_DUMMY_H_ |
6 |
|
|
#define CVMFS_SYNC_ITEM_DUMMY_H_ |
7 |
|
|
|
8 |
|
|
#include "sync_item.h" |
9 |
|
|
|
10 |
|
|
#include <ctime> |
11 |
|
|
#include <string> |
12 |
|
|
|
13 |
|
|
#include "sync_union_tarball.h" |
14 |
|
|
|
15 |
|
|
namespace publish { |
16 |
|
|
/* |
17 |
|
|
* This class represents dummy directories that we know are going to be there |
18 |
|
|
* but we still haven't found yet. This is possible in the extraction of |
19 |
|
|
* tarball, where the files are not extracted in order (root to leaves) but in a |
20 |
|
|
* random fashion. |
21 |
|
|
*/ |
22 |
|
|
class SyncItemDummyDir : public SyncItemNative { |
23 |
|
|
friend class SyncUnionTarball; |
24 |
|
|
|
25 |
|
|
public: |
26 |
|
|
catalog::DirectoryEntryBase CreateBasicCatalogDirent() const; |
27 |
|
|
SyncItemType GetScratchFiletype() const; |
28 |
|
|
virtual void MakePlaceholderDirectory() const { rdonly_type_ = kItemDir; } |
29 |
|
|
|
30 |
|
|
protected: |
31 |
|
|
SyncItemDummyDir(const std::string &relative_parent_path, |
32 |
|
|
const std::string &filename, const SyncUnion *union_engine, |
33 |
|
|
const SyncItemType entry_type) |
34 |
|
|
: SyncItemNative(relative_parent_path, filename, union_engine, |
35 |
|
|
entry_type) { |
36 |
|
|
assert(kItemDir == entry_type); |
37 |
|
|
|
38 |
|
|
scratch_stat_.obtained = true; |
39 |
|
|
scratch_stat_.stat.st_mode = kPermision; |
40 |
|
|
scratch_stat_.stat.st_nlink = 1; |
41 |
|
|
scratch_stat_.stat.st_uid = getuid(); |
42 |
|
|
scratch_stat_.stat.st_gid = getgid(); |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
private: |
46 |
|
|
static const mode_t kPermision = S_IFDIR | S_IRUSR | S_IWUSR | S_IXUSR | |
47 |
|
|
S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; |
48 |
|
|
}; |
49 |
|
|
|
50 |
|
|
catalog::DirectoryEntryBase SyncItemDummyDir::CreateBasicCatalogDirent() const { |
51 |
|
|
catalog::DirectoryEntryBase dirent; |
52 |
|
|
|
53 |
|
|
dirent.inode_ = catalog::DirectoryEntry::kInvalidInode; |
54 |
|
|
|
55 |
|
|
dirent.linkcount_ = 1; |
56 |
|
|
|
57 |
|
|
dirent.mode_ = kPermision; |
58 |
|
|
|
59 |
|
|
dirent.uid_ = scratch_stat_.stat.st_uid; |
60 |
|
|
dirent.gid_ = scratch_stat_.stat.st_gid; |
61 |
|
|
dirent.size_ = 4096; |
62 |
|
|
dirent.mtime_ = time(NULL); |
63 |
|
|
dirent.checksum_ = this->GetContentHash(); |
64 |
|
|
dirent.is_external_file_ = this->IsExternalData(); |
65 |
|
|
dirent.compression_algorithm_ = this->GetCompressionAlgorithm(); |
66 |
|
|
|
67 |
|
|
dirent.name_.Assign(this->filename().data(), this->filename().length()); |
68 |
|
|
|
69 |
|
|
assert(dirent.IsDirectory()); |
70 |
|
|
|
71 |
|
|
return dirent; |
72 |
|
|
} |
73 |
|
|
|
74 |
|
|
|
75 |
|
|
SyncItemType SyncItemDummyDir::GetScratchFiletype() const { |
76 |
|
|
return kItemDir; |
77 |
|
|
} |
78 |
|
|
|
79 |
|
|
} // namespace publish |
80 |
|
|
|
81 |
|
|
#endif // CVMFS_SYNC_ITEM_DUMMY_H_ |