aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers/importExportController.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2019-10-08 20:52:03 +0200
committerGravatar GitHub <noreply@github.com> 2019-10-08 20:52:03 +0200
commit077e3cff458e4c36b364c065397d524025ee3de1 (patch)
treed25d02fb5c5a2d625d6499f8ad204f64839843c4 /app/Controllers/importExportController.php
parentac9e2df7f8c8d49750ecf28a3afbbe0bfb6d571d (diff)
Increase import size (#2563)
* Increase import size This is merely a temporary workaround to allow at least some medium size imports https://framateam.org/freshrss/pl/7wbt4tcyetrfmris9xdcbq7uuw The import module should be rewritten to process files one by one and as data streams instead of loading multiple copies of the whole dataset in memory as is the case now :-( https://github.com/FreshRSS/FreshRSS/issues/1890 Note that the new SQLite export/import is distinct from this case. * Use parameter
Diffstat (limited to 'app/Controllers/importExportController.php')
-rw-r--r--app/Controllers/importExportController.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php
index 93897dde5..f2ae8238e 100644
--- a/app/Controllers/importExportController.php
+++ b/app/Controllers/importExportController.php
@@ -29,7 +29,25 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
Minz_View::prependTitle(_t('sub.import_export.title') . ' ยท ');
}
+ private static function megabytes($size_str) {
+ switch (substr($size_str, -1)) {
+ case 'M': case 'm': return (int)$size_str;
+ case 'K': case 'k': return (int)$size_str / 1024;
+ case 'G': case 'g': return (int)$size_str * 1024;
+ }
+ return $size_str;
+ }
+
+ private static function minimumMemory($mb) {
+ $mb = (int)$mb;
+ $ini = self::megabytes(ini_get('memory_limit'));
+ if ($ini < $mb) {
+ ini_set('memory_limit', $mb . 'M');
+ }
+ }
+
public function importFile($name, $path, $username = null) {
+ self::minimumMemory(256);
require_once(LIB_PATH . '/lib_opml.php');
$this->catDAO = new FreshRSS_CategoryDAO($username);