MCPcopy Create free account
hub / github.com/error311/FileRise / create

Method create

src/FileRise/Domain/TransferJobManager.php:92–124  ·  view source on GitHub ↗
(array $job)

Source from the content-addressed store, hash-verified

90 }
91
92 public static function create(array $job): array
93 {
94 self::ensureDirs();
95
96 $jobId = bin2hex(random_bytes(16));
97 $now = time();
98 $doc = array_merge([
99 'id' => $jobId,
100 'status' => 'queued',
101 'createdAt' => $now,
102 'updatedAt' => $now,
103 'startedAt' => null,
104 'endedAt' => null,
105 'cancelRequested' => false,
106 'error' => null,
107 'errors' => [],
108 'current' => null,
109 'phase' => 'queued',
110 'pct' => 0,
111 'filesDone' => 0,
112 'bytesDone' => 0,
113 'selectedFiles' => 0,
114 'selectedBytes' => 0,
115 ], $job);
116
117 $path = self::pathFor($jobId);
118 $ok = @file_put_contents($path, json_encode($doc, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), LOCK_EX);
119 if ($ok === false) {
120 throw new \RuntimeException('Failed to create transfer job.');
121 }
122 @chmod($path, 0600);
123 return ['id' => $jobId, 'path' => $path, 'job' => $doc];
124 }
125
126 public static function listForUser(string $username, bool $isAdmin = false, int $limit = 50): array
127 {

Callers 4

main.jsFile · 0.80
enqueueTransferJobMethod · 0.80
enqueueTransferJobMethod · 0.80
setupTOTPMethod · 0.80

Calls 2

ensureDirsMethod · 0.95
pathForMethod · 0.95

Tested by

no test coverage detected