Skip to content
This repository was archived by the owner on Mar 29, 2024. It is now read-only.

Commit af60fd8

Browse files
committed
Fix PHPUnit error on Windows
1 parent d178e93 commit af60fd8

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/com/carlgo11/tempfiles/datastorage/FileStorage.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ public function saveEntry(EncryptedFile $file, string $password) {
6161
$newFile = fopen($conf['file-path'] . $file, "w");
6262

6363
// Get expiry date if file already exists
64-
if ($this->entryExists($file)) $expiry = $this->getExpiry($file);
65-
else $expiry = (new DateTime('+1 day'))->getTimestamp();
64+
if (($expiry = $this->getExpiry($file)) === NULL) $expiry = (new DateTime('+1 day'))->getTimestamp();
6665

6766
$content = [
6867
'expiry' => $expiry,
@@ -85,11 +84,12 @@ public function saveEntry(EncryptedFile $file, string $password) {
8584
* @since 2.5
8685
*/
8786
private function getExpiry(string $id) {
87+
if (!$this->entryExists($id)) return NULL;
8888
global $conf;
89-
if (!$this->entryExists($id)) return NULL; // NOTE: Will always return NULL when run inside WSL
9089

9190
$file = file_get_contents($conf['file-path'] . $id);
9291
$data = json_decode($file, TRUE);
92+
if ($data === NULL) return NULL;
9393
return $data['expiry'];
9494
}
9595

tests/com/carlgo11/tempfiles/datastorage/DataStorageTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function testSaveFile() {
1515
$file->setContent(random_bytes(2.097 * 10 ^ 6)); // Generate random 2MB content
1616
$file->setMetaData(['size' => 2048, 'name' => 'test.jpg', 'type' => 'image/jpeg']);
1717
$file->setDeletionPassword(Misc::generatePassword(12, 32));
18-
18+
print("Saving file...");
1919
$this->assertTrue(DataStorage::saveFile($file, $password));
2020
sleep(1);
2121
print("Fetching file...");

0 commit comments

Comments
 (0)