|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace App\Enums; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Collection filecheck status values used during release processing. |
|
9
|
|
|
* |
|
10
|
|
|
* These statuses track the progress of collections through the release |
|
11
|
|
|
* creation pipeline, from initial discovery to NZB file creation. |
|
12
|
|
|
*/ |
|
13
|
|
|
enum CollectionFileCheckStatus: int |
|
14
|
|
|
{ |
|
15
|
|
|
/** Default status for newly discovered collections */ |
|
16
|
|
|
case Default = 0; |
|
17
|
|
|
|
|
18
|
|
|
/** Collection has all expected binary files */ |
|
19
|
|
|
case CompleteCollection = 1; |
|
20
|
|
|
|
|
21
|
|
|
/** All parts of binaries are complete */ |
|
22
|
|
|
case CompleteParts = 2; |
|
23
|
|
|
|
|
24
|
|
|
/** Collection size has been calculated */ |
|
25
|
|
|
case Sized = 3; |
|
26
|
|
|
|
|
27
|
|
|
/** Collection has been converted to a release */ |
|
28
|
|
|
case Inserted = 4; |
|
29
|
|
|
|
|
30
|
|
|
/** Collection marked for deletion */ |
|
31
|
|
|
case Delete = 5; |
|
32
|
|
|
|
|
33
|
|
|
/** Temporary complete status during processing */ |
|
34
|
|
|
case TempComplete = 15; |
|
35
|
|
|
|
|
36
|
|
|
/** Collection has zero-numbered parts (special handling) */ |
|
37
|
|
|
case ZeroPart = 16; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Get the human-readable description for this status. |
|
41
|
|
|
*/ |
|
42
|
|
|
public function description(): string |
|
43
|
|
|
{ |
|
44
|
|
|
return match ($this) { |
|
45
|
|
|
self::Default => 'Newly discovered', |
|
46
|
|
|
self::CompleteCollection => 'Complete collection', |
|
47
|
|
|
self::CompleteParts => 'Complete parts', |
|
48
|
|
|
self::Sized => 'Size calculated', |
|
49
|
|
|
self::Inserted => 'Inserted as release', |
|
50
|
|
|
self::Delete => 'Marked for deletion', |
|
51
|
|
|
self::TempComplete => 'Temporarily complete', |
|
52
|
|
|
self::ZeroPart => 'Zero-part collection', |
|
53
|
|
|
}; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Check if this status indicates processing is complete. |
|
58
|
|
|
*/ |
|
59
|
|
|
public function isProcessingComplete(): bool |
|
60
|
|
|
{ |
|
61
|
|
|
return match ($this) { |
|
62
|
|
|
self::Inserted, self::Delete => true, |
|
63
|
|
|
default => false, |
|
64
|
|
|
}; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Get statuses that indicate a collection is ready for release creation. |
|
69
|
|
|
* |
|
70
|
|
|
* @return array<self> |
|
71
|
|
|
*/ |
|
72
|
|
|
public static function readyForRelease(): array |
|
73
|
|
|
{ |
|
74
|
|
|
return [self::Sized]; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Get statuses that indicate a collection is still being processed. |
|
79
|
|
|
* |
|
80
|
|
|
* @return array<self> |
|
81
|
|
|
*/ |
|
82
|
|
|
public static function inProgress(): array |
|
83
|
|
|
{ |
|
84
|
|
|
return [ |
|
85
|
|
|
self::Default, |
|
86
|
|
|
self::CompleteCollection, |
|
87
|
|
|
self::CompleteParts, |
|
88
|
|
|
self::TempComplete, |
|
89
|
|
|
self::ZeroPart, |
|
90
|
|
|
]; |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|