blib/lib/App/FileSync/Constants.pm

filter: Statementstmt 100% 52 / 52 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 100% 57 / 57 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 341 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 341 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 341 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 341 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 341 ▶use version; our $VERSION = version->declare('0.002.1');
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 341 Readonly::Scalar our $EXIT_OK => 0;
22 341 Readonly::Scalar our $EXIT_FATAL => 1;
23 341 Readonly::Scalar our $EXIT_LOCKED => 2;
24 341 Readonly::Scalar our $EXIT_WARNINGS => 3;
25 341 Readonly::Scalar our $EXIT_DRIFT => 4;
26  
27 # Highest exit status a process can report; "--exit N" is checked against it.
28 341 Readonly::Scalar our $EXIT_MAX => 255;
29  
30 # Wire protocol version spoken by this release; client and server must agree.
31 341 Readonly::Scalar our $PROTOCOL_VERSION => 2;
32  
33 # Where the server tree lives when neither --root nor FILESYNC_ROOT says.
34 341 Readonly::Scalar our $DEFAULT_SERVER_ROOT => '/srv/filesync';
35  
36 # The program sshd runs as the forced command.
37 341 Readonly::Scalar our $SERVER_PROGRAM => 'filesync-server';
38  
39 # Session roles. A replica only ever pulls.
40 341 Readonly::Scalar our $ROLE_CLIENT => 'client';
41 341 Readonly::Scalar our $ROLE_REPLICA => 'replica';
42 341 Readonly our @ROLES => ($ROLE_CLIENT, $ROLE_REPLICA);
43  
44 # Manifest entry types.
45 341 Readonly::Scalar our $TYPE_FILE => 'f';
46 341 Readonly::Scalar our $TYPE_DIR => 'd';
47  
48 # Fields of the list stat() and lstat() return.
49 341 Readonly::Scalar our $STAT_MODE => 2;
50 341 Readonly::Scalar our $STAT_SIZE => 7;
51 341 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 341 Readonly::Scalar our $MODE_MASK => oct('7777');
56 341 Readonly::Scalar our $DEFAULT_FILE_MODE => oct('644');
57  
58 # Reserved names inside a sync root or the master.
59 341 Readonly::Scalar our $ROOT_MARKER => '.filesync-root';
60 341 Readonly::Scalar our $TEMP_PREFIX => '.filesync-tmp-';
61 341 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 341 Readonly::Scalar our $STALE_TEMP_SECONDS => 3600;
66  
67 # Largest single data frame either side accepts for an upload chunk.
68 341 Readonly::Scalar our $MAX_CHUNK_BYTES => 8 * 1024 * 1024;
69  
70 # Repo policy defaults, also used when a stored config omits a key.
71 341 Readonly::Scalar our $TRASH_DAYS => 30;
72 341 Readonly::Scalar our $MAX_DELETES => 200;
73 341 Readonly::Scalar our $MAX_DELETE_PERCENT => 10;
74  
75 # Replica snapshots kept by "filesync snapshot" when nothing says otherwise.
76 341 Readonly::Scalar our $SNAPSHOT_KEEP => 14;
77  
78 # Calendar arithmetic.
79 341 Readonly::Scalar our $SECONDS_PER_DAY => 86_400;
80  
81 # Repo and client ids become directory names, so they are short.
82 341 Readonly::Scalar our $MAX_ID_LENGTH => 64;
83  
84 # The Digest::SHA algorithm behind every content hash.
85 341 Readonly::Scalar our $SHA_BITS => 256;
86  
87 # A SHA-256 digest as it appears on the wire and in the index.
88 341 Readonly our $SHA256_HEX => qr/\A[0-9a-f]{64}\z/;
89  
90 # Two clocks are treated as agreeing within this many seconds (FAT stores
91 # mtimes in 2-second units).
92 341 Readonly::Scalar our $MTIME_TOLERANCE => 2;
93  
94 341 our @EXPORT_OK = qw(
95 $EXIT_OK $EXIT_FATAL $EXIT_LOCKED $EXIT_WARNINGS $EXIT_DRIFT $EXIT_MAX
96 $PROTOCOL_VERSION $DEFAULT_SERVER_ROOT $SERVER_PROGRAM
97 $ROLE_CLIENT $ROLE_REPLICA @ROLES
98 $TYPE_FILE $TYPE_DIR
99 $STAT_MODE $STAT_SIZE $STAT_MTIME
100 $MODE_MASK $DEFAULT_FILE_MODE
101 $ROOT_MARKER $TEMP_PREFIX $SNAPSHOT_DIR $STALE_TEMP_SECONDS
102 $MAX_CHUNK_BYTES
103 $TRASH_DAYS $MAX_DELETES $MAX_DELETE_PERCENT $SNAPSHOT_KEEP
104 $SECONDS_PER_DAY $MAX_ID_LENGTH $SHA_BITS $SHA256_HEX $MTIME_TOLERANCE
105 );
106  
107 341 our %EXPORT_TAGS = (all => \@EXPORT_OK);
108  
109 341 1;
110  
111 __END__
« blib/lib/App/FileSync/Base.pm ↑ Summary blib/lib/App/FileSync/I18N/en.pm »