blib/lib/App/FileSync/Constants.pm

filter: Statementstmt 100% 53 / 53 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 100% 58 / 58 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/App/FileSync/Base.pm ↑ Summary blib/lib/App/FileSync/I18N/en.pm »
1 package App::FileSync::Constants;
2  
3 # Every fixed number and reserved name the distribution shares. Tunables that
4 # tests adjust with "local" (chunk sizes, the run-log limit, the delta
5 # thresholds) stay as package variables in their own modules instead.
6  
7 444 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 444 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 444 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 444 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 444 ▶use version; our $VERSION = version->declare('0.002.2');
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 # Plain values use Readonly::Scalar: it sets Perl's own read-only flag, where
16 # "Readonly our $X" ties the variable and makes every read a method call
17 # (about nine times slower). Several of these are read once per file. The
18 # pattern and the list keep Readonly, which handles references.
19  
20 # Exit codes: the contract with cron, the Task Scheduler and "--exit N".
21 444 Readonly::Scalar our $EXIT_OK => 0;
22 444 Readonly::Scalar our $EXIT_FATAL => 1;
23 444 Readonly::Scalar our $EXIT_LOCKED => 2;
24 444 Readonly::Scalar our $EXIT_WARNINGS => 3;
25 444 Readonly::Scalar our $EXIT_DRIFT => 4;
26  
27 # Highest exit status a process can report; "--exit N" is checked against it.
28 444 Readonly::Scalar our $EXIT_MAX => 255;
29  
30 # Wire protocol version spoken by this release; client and server must agree.
31 444 Readonly::Scalar our $PROTOCOL_VERSION => 2;
32  
33 # Where the server tree lives when neither --root nor FILESYNC_ROOT says.
34 444 Readonly::Scalar our $DEFAULT_SERVER_ROOT => '/srv/filesync';
35  
36 # The program sshd runs as the forced command.
37 444 Readonly::Scalar our $SERVER_PROGRAM => 'filesync-server';
38  
39 # Session roles. A replica only ever pulls.
40 444 Readonly::Scalar our $ROLE_CLIENT => 'client';
41 444 Readonly::Scalar our $ROLE_REPLICA => 'replica';
42 444 Readonly our @ROLES => ($ROLE_CLIENT, $ROLE_REPLICA);
43  
44 # Manifest entry types.
45 444 Readonly::Scalar our $TYPE_FILE => 'f';
46 444 Readonly::Scalar our $TYPE_DIR => 'd';
47  
48 # Fields of the list stat() and lstat() return.
49 444 Readonly::Scalar our $STAT_MODE => 2;
50 444 Readonly::Scalar our $STAT_SIZE => 7;
51 444 Readonly::Scalar our $STAT_MTIME => 9;
52  
53 # Permission bits worth carrying between machines, and the mode a file gets
54 # when the peer did not send one.
55 444 Readonly::Scalar our $MODE_MASK => oct('7777');
56 444 Readonly::Scalar our $DEFAULT_FILE_MODE => oct('644');
57  
58 # Reserved names inside a sync root or the master.
59 444 Readonly::Scalar our $ROOT_MARKER => '.filesync-root';
60 444 Readonly::Scalar our $TEMP_PREFIX => '.filesync-tmp-';
61 444 Readonly::Scalar our $SNAPSHOT_DIR => '.filesync-snapshots';
62  
63 # Temporaries older than this are from a run that died; younger ones may
64 # belong to a run in progress.
65 444 Readonly::Scalar our $STALE_TEMP_SECONDS => 3600;
66  
67 # Largest single data frame either side accepts for an upload chunk.
68 444 Readonly::Scalar our $MAX_CHUNK_BYTES => 8 * 1024 * 1024;
69  
70 # Repo policy defaults, also used when a stored config omits a key.
71 444 Readonly::Scalar our $TRASH_DAYS => 30;
72 444 Readonly::Scalar our $MAX_DELETES => 200;
73 444 Readonly::Scalar our $MAX_DELETE_PERCENT => 10;
74  
75 # The most max_delete_percent can be: a percentage of the repo.
76 444 Readonly::Scalar our $MAX_PERCENT => 100;
77  
78 # Replica snapshots kept by "filesync snapshot" when nothing says otherwise.
79 444 Readonly::Scalar our $SNAPSHOT_KEEP => 14;
80  
81 # Calendar arithmetic.
82 444 Readonly::Scalar our $SECONDS_PER_DAY => 86_400;
83  
84 # Repo and client ids become directory names, so they are short.
85 444 Readonly::Scalar our $MAX_ID_LENGTH => 64;
86  
87 # The Digest::SHA algorithm behind every content hash.
88 444 Readonly::Scalar our $SHA_BITS => 256;
89  
90 # A SHA-256 digest as it appears on the wire and in the index.
91 444 Readonly our $SHA256_HEX => qr/\A[0-9a-f]{64}\z/;
92  
93 # Two clocks are treated as agreeing within this many seconds (FAT stores
94 # mtimes in 2-second units).
95 444 Readonly::Scalar our $MTIME_TOLERANCE => 2;
96  
97 444 our @EXPORT_OK = qw(
98 $EXIT_OK $EXIT_FATAL $EXIT_LOCKED $EXIT_WARNINGS $EXIT_DRIFT $EXIT_MAX
99 $PROTOCOL_VERSION $DEFAULT_SERVER_ROOT $SERVER_PROGRAM
100 $ROLE_CLIENT $ROLE_REPLICA @ROLES
101 $TYPE_FILE $TYPE_DIR
102 $STAT_MODE $STAT_SIZE $STAT_MTIME
103 $MODE_MASK $DEFAULT_FILE_MODE
104 $ROOT_MARKER $TEMP_PREFIX $SNAPSHOT_DIR $STALE_TEMP_SECONDS
105 $MAX_CHUNK_BYTES
106 $TRASH_DAYS $MAX_DELETES $MAX_DELETE_PERCENT $MAX_PERCENT $SNAPSHOT_KEEP
107 $SECONDS_PER_DAY $MAX_ID_LENGTH $SHA_BITS $SHA256_HEX $MTIME_TOLERANCE
108 );
109  
110 444 our %EXPORT_TAGS = (all => \@EXPORT_OK);
111  
112 444 1;
113  
114 __END__
« blib/lib/App/FileSync/Base.pm ↑ Summary blib/lib/App/FileSync/I18N/en.pm »