Overview
Comment:Fix error on SQLite file storage when overwriting an existing file
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | stable
Files: files | file ages | folders
SHA3-256: 6ade070e7687dc957c572533c1984b3592b63b66458e549b876138231537783d
User & Date: bohwaz on 2021-11-01 15:24:45
Other Links: manifest | tags
Context
2021-11-03
17:37
Fix: config is not required here check-in: 2239ebd2fa user: bohwaz tags: trunk, stable
2021-11-01
15:24
Fix error on SQLite file storage when overwriting an existing file check-in: 6ade070e76 user: bohwaz tags: trunk, stable
15:11
Fix: error message when trying to have two subscriptions for the same service the same day check-in: 718020831b user: bohwaz tags: trunk, stable
Changes

Modified src/include/lib/Garradin/Entities/Files/File.php from [2f3a044bb4] to [e939566187].

382
383
384
385
386
387
388
389


390
391
392
393
394
395
396
397
			throw new \InvalidArgumentException('Either source path or source content should be set but not both');
		}

		self::validateFileName($name);
		self::ensureDirectoryExists($path);

		$finfo = \finfo_open(\FILEINFO_MIME_TYPE);
		$file = new self;


		$file->set('path', $path . '/' . $name);
		$file->set('parent', $path);
		$file->set('name', $name);

		if ($source_path && !$source_content) {
			$file->set('mime', finfo_file($finfo, $source_path));
			$file->set('size', filesize($source_path));
		}







|
>
>
|







382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
			throw new \InvalidArgumentException('Either source path or source content should be set but not both');
		}

		self::validateFileName($name);
		self::ensureDirectoryExists($path);

		$finfo = \finfo_open(\FILEINFO_MIME_TYPE);

		$fullpath = $path . '/' . $name;
		$file = Files::callStorage('get', $fullpath) ?: new self;
		$file->set('path', $fullpath);
		$file->set('parent', $path);
		$file->set('name', $name);

		if ($source_path && !$source_content) {
			$file->set('mime', finfo_file($finfo, $source_path));
			$file->set('size', filesize($source_path));
		}
884
885
886
887
888
889
890



891
892
893
894
895
896
897
			$format = Render::FORMAT_SKRIV;
		}
		elseif (substr($this->name, -3) == '.md') {
			$format = Render::FORMAT_MARKDOWN;
		}
		else if (substr($this->mime, 0, 5) == 'text/') {
			$format = 'text';



		}
		else {
			$format = null;
		}

		return $format;
	}







>
>
>







886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
			$format = Render::FORMAT_SKRIV;
		}
		elseif (substr($this->name, -3) == '.md') {
			$format = Render::FORMAT_MARKDOWN;
		}
		else if (substr($this->mime, 0, 5) == 'text/') {
			$format = 'text';
		}
		else if ($this->size == 0) {
			$format = 'text';
		}
		else {
			$format = null;
		}

		return $format;
	}