Skip to content

Commit c0b48fc

Browse files
committed
better naming of archives
1 parent 5273590 commit c0b48fc

File tree

5 files changed

+296
-161
lines changed

5 files changed

+296
-161
lines changed

lib/Listeners/NodeEvent.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141
use OCP\Files\Events\Node\NodeCreatedEvent;
4242
use OCP\Files\Events\Node\NodeRenamedEvent;
4343
use OCP\Files\Events\Node\NodeWrittenEvent;
44-
use OCP\Files\InvalidPathException;
45-
use OCP\Files\NotFoundException;
4644

4745

4846
/**
@@ -74,9 +72,6 @@ public function __construct(FilesService $filesService) {
7472

7573
/**
7674
* @param Event $event
77-
*
78-
* @throws InvalidPathException
79-
* @throws NotFoundException
8075
*/
8176
public function handle(Event $event): void {
8277
$node = null;

lib/Model/RestoringChunk.php

Lines changed: 15 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ class RestoringChunk implements JsonSerializable, IDeserializable {
5959
/** @var string[] */
6060
private $files = [];
6161

62+
/** @var RestoringChunkPart */
63+
private $parts = [];
64+
6265
/** @var int */
6366
private $count = 0;
6467

@@ -69,42 +72,33 @@ class RestoringChunk implements JsonSerializable, IDeserializable {
6972
private $checksum = '';
7073

7174
/** @var bool */
72-
private $encrypted = false;
75+
private $stored = false;
7376

7477
/** @var bool */
7578
private $staticName = false;
7679

77-
/** @var string */
78-
private $encryptedChecksum = '';
79-
8080

8181
/**
82-
* only add $name for specific Chunk.
83-
*
8482
* RestoringChunk constructor.
8583
*/
86-
public function __construct(string $name = '') {
87-
if ($name === '') {
88-
$name = $this->uuid();
89-
} else {
90-
$this->staticName = true;
84+
public function __construct(string $name = '', bool $staticName = false) {
85+
$this->staticName = $staticName;
86+
if (!$staticName) {
87+
if ($name !== '') {
88+
$name .= '-';
89+
}
90+
$name .= $this->uuid();
9191
}
9292

9393
$this->name = $name;
9494
}
9595

9696

9797
/**
98-
* @param string $ext
99-
*
10098
* @return string
10199
*/
102-
public function getName(string $ext = ''): string {
103-
if ($ext === '') {
104-
return $this->name;
105-
}
106-
107-
return $this->name . '.' . $ext;
100+
public function getName(): string {
101+
return $this->name;
108102
}
109103

110104
/**
@@ -146,21 +140,10 @@ public function getFilename(): string {
146140
return $this->getName();
147141
}
148142

149-
if ($this->isEncrypted()) {
150-
return $this->getName();
151-
}
152-
153143
return $this->getName() . '.zip';
154144
}
155145

156146

157-
// /**
158-
// * @return int
159-
// */
160-
// public function count(): int {
161-
// return sizeof($this->files);
162-
// }
163-
//
164147
/**
165148
* @return int
166149
*/
@@ -233,25 +216,6 @@ public function setSize(int $size): self {
233216
}
234217

235218

236-
/**
237-
* @param bool $encrypted
238-
*
239-
* @return RestoringChunk
240-
*/
241-
public function setEncrypted(bool $encrypted): self {
242-
$this->encrypted = $encrypted;
243-
244-
return $this;
245-
}
246-
247-
/**
248-
* @return bool
249-
*/
250-
public function isEncrypted(): bool {
251-
return $this->encrypted;
252-
}
253-
254-
255219
/**
256220
* @return string
257221
*/
@@ -270,36 +234,6 @@ public function setChecksum(string $checksum): self {
270234
return $this;
271235
}
272236

273-
/**
274-
* @param string $checksum
275-
*
276-
* @return bool
277-
*/
278-
public function compareChecksum(string $checksum): bool {
279-
if ($this->isEncrypted()) {
280-
return ($this->getEncryptedChecksum() === $checksum);
281-
}
282-
283-
return ($this->getChecksum() === $checksum);
284-
}
285-
286-
/**
287-
* @return string
288-
*/
289-
public function getEncryptedChecksum(): string {
290-
return $this->encryptedChecksum;
291-
}
292-
293-
/**
294-
* @param string $encryptedChecksum
295-
*
296-
* @return RestoringChunk
297-
*/
298-
public function setEncryptedChecksum(string $encryptedChecksum): self {
299-
$this->encryptedChecksum = $encryptedChecksum;
300-
301-
return $this;
302-
}
303237

304238
/**
305239
* @param string $content
@@ -331,10 +265,8 @@ public function import(array $data): IDeserializable {
331265
->setCount($this->getInt('count', $data))
332266
->setSize($this->getInt('size', $data))
333267
->setContent($this->get('content', $data))
334-
->setEncrypted($this->getBool('encrypted', $data))
335268
->setStaticName($this->getBool('staticName', $data))
336-
->setChecksum($this->get('checksum', $data))
337-
->setEncryptedChecksum($this->get('encryptedChecksum', $data));
269+
->setChecksum($this->get('checksum', $data));
338270

339271
return $this;
340272
}
@@ -358,10 +290,8 @@ public function jsonSerialize(): array {
358290
'name' => $this->getName(),
359291
'count' => $this->getCount(),
360292
'size' => $this->getSize(),
361-
'encrypted' => $this->isEncrypted(),
362293
'staticName' => $this->isStaticName(),
363-
'checksum' => $this->getChecksum(),
364-
'encryptedChecksum' => $this->getEncryptedChecksum()
294+
'checksum' => $this->getChecksum()
365295
];
366296

367297
if ($this->getContent() !== '') {
@@ -371,6 +301,5 @@ public function jsonSerialize(): array {
371301
return $arr;
372302
}
373303

374-
375304
}
376305

0 commit comments

Comments
 (0)