Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Office-files get deleted #33160

Closed
micropurpose opened this issue Oct 11, 2018 · 4 comments · Fixed by #33232
Closed

Office-files get deleted #33160

micropurpose opened this issue Oct 11, 2018 · 4 comments · Fixed by #33232
Assignees
Milestone

Comments

@micropurpose
Copy link

micropurpose commented Oct 11, 2018

Hi!

I'm running ownCloud 10.0.10 (production) on Debian GNU/Linux 8.

Browsing a folder via WebGUI will delete all ms-office-documents in view.
Other files types or not affected.

Steps to reproduce

  1. Open folder via GUI

access.log

[11/Oct/2018:18:12:16 +0200] "GET /ocs/v2.php/apps/notifications/api/v1/notifications?format=json HTTP/1.1" 200 1048 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"
[11/Oct/2018:18:12:16 +0200] "GET /ocs/v2.php/apps/notifications/api/v1/notifications?format=json HTTP/1.1" 200 910 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"
[11/Oct/2018:18:12:27 +0200] "GET /ocs/v2.php/apps/notifications/api/v1/notifications?format=json HTTP/1.1" 200 1048 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"
[11/Oct/2018:18:12:32 +0200] "PROPFIND /remote.php/webdav/save HTTP/1.1" 207 460670 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"
[11/Oct/2018:18:12:33 +0200] "GET /index.php/apps/files/ajax/getstoragestats.php?dir=%2Fsave HTTP/1.1" 200 1018 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"
[11/Oct/2018:18:12:33 +0200] "GET /remote.php/dav/files/bbb/save/IMG_20180917_131442.jpg?c=c411bac75531448a4ca6fd8c4a96ef4d&x=64&y=64&forceIcon=0&preview=1 HTTP/1.1" 200 2648 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"
[11/Oct/2018:18:12:33 +0200] "GET /remote.php/dav/files/bbb/save/IMG_20180917_131935.jpg?c=XXXe3f1ec966b27da6ae9c4ffea7&x=64&y=64&forceIcon=0&preview=1 HTTP/1.1" 200 2723 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"
[11/Oct/2018:18:12:33 +0200] "GET /remote.php/dav/files/bbb/save/StromVergleich2018.xlsx?c=XXX16c296868e60ec06cb72b4c1&x=64&y=64&forceIcon=0&preview=1 HTTP/1.1" 404 9143 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"

iWatch-Log

Oct 11 18:12:33 system iWatch[3979]: * /owncloud/data/bbb/files/save/StromVergleich2018.xlsx is deleted

owncloud-log

{"reqId":"W792awUJIMQAADJctv4AAAAK","level":0,"time":"2018-10-11T16:12:27+00:00","remoteAddr":"XXX","user":"bb","app":"OC\User\Session::validateToken","method":"GET","url":"/ocs/v2.php/apps/notifications/api/v1/notifications?format=json","message":"token TTT with token id 1389 found, validating"}
{"reqId":"W792awUJIMQAADJctv4AAAAK","level":0,"time":"2018-10-11T16:12:27+00:00","remoteAddr":"XXX","user":"bb","app":"OC\Authentication\Token\DefaultTokenProvider::updateTokenActivity","method":"GET","url":"/ocs/v2.php/apps/notifications/api/v1/notifications?format=json","message":"updating activity of token 1389 to 1539274347"}
{"reqId":"W792awUJIMQAADJctv4AAAAK","level":0,"time":"2018-10-11T16:12:27+00:00","remoteAddr":"XXX","user":"bb","app":"OC\User\Session::validateToken","method":"GET","url":"/ocs/v2.php/apps/notifications/api/v1/notifications?format=json","message":"token TTT with token id 1389 found, validating"}
{"reqId":"W792cAUJIMQAADJctv8AAAAK","level":0,"time":"2018-10-11T16:12:32+00:00","remoteAddr":"XXX","user":"bb","app":"OC\User\Session::validateToken","method":"PROPFIND","url":"/remote.php/webdav/save","message":"token TTT with token id 1389 found, validating"}
{"reqId":"W792cQUJIMQAADJctwAAAAAK","level":0,"time":"2018-10-11T16:12:33+00:00","remoteAddr":"XXX","user":"bb","app":"OC\User\Session::validateToken","method":"GET","url":"/index.php/apps/files/ajax/getstoragestats.php?dir=%2Fsave","message":"token TTT with token id 1389 found, validating"}
{"reqId":"W792cQUJIMQAADJctwAAAAAK","level":0,"time":"2018-10-11T16:12:33+00:00","remoteAddr":"XXX","user":"bb","app":"OC\User\Session::validateToken","method":"GET","url":"/index.php/apps/files/ajax/getstoragestats.php?dir=%2Fsave","message":"token TTT with token id 1389 found, validating"}
{"reqId":"W792cQUJIMQAADJctwAAAAAK","level":0,"time":"2018-10-11T16:12:33+00:00","remoteAddr":"XXX","user":"bb","app":"OC\User\Session::validateToken","method":"GET","url":"/index.php/apps/files/ajax/getstoragestats.php?dir=%2Fsave","message":"token TTT with token id 1389 found, validating"}
{"reqId":"W792cQUJIMQAADcrmMYAAAAO","level":0,"time":"2018-10-11T16:12:33+00:00","remoteAddr":"XXX","user":"bb","app":"OC\User\Session::validateToken","method":"GET","url":"/remote.php/dav/files/bb/save/IMG_20180917_131442.jpg?c=ooo&x=64&y=64&forceIcon=0&preview=1","message":"token TTT with token id 1389 found, validating"}
{"reqId":"W792cQUJIMQAAF6jU@AAAAAD","level":0,"time":"2018-10-11T16:12:33+00:00","remoteAddr":"XXX","user":"bb","app":"OC\User\Session::validateToken","method":"GET","url":"/remote.php/dav/files/bb/save/StromVergleich2018.xlsx?c=ttt&x=64&y=64&forceIcon=0&preview=1","message":"token TTT with token id 1389 found, validating"}
{"reqId":"W792cQUJIMQAAGnWa6cAAAAA","level":0,"time":"2018-10-11T16:12:33+00:00","remoteAddr":"XXX","user":"bb","app":"OC\User\Session::validateToken","method":"GET","url":"/remote.php/dav/files/bb/save/IMG_20180917_131935.jpg?c=zzz&x=64&y=64&forceIcon=0&preview=1","message":"token TTT with token id 1389 found, validating"}
{"reqId":"W792cQUJIMQAAF6jU@AAAAAD","level":0,"time":"2018-10-11T16:12:33+00:00","remoteAddr":"XXX","user":"bb","app":"core","method":"GET","url":"/remote.php/dav/files/bb/save/StromVergleich2018.xlsx?c=ttt&x=64&y=64&forceIcon=0&preview=1","message":"Generating preview for "/bb/files/save/StromVergleich2018.xlsx" with "OC\Preview\MSOffice2007""}
{"reqId":"W792cQUJIMQAAF6jU@AAAAAD","level":3,"time":"2018-10-11T16:12:33+00:00","remoteAddr":"XXX","user":"bb","app":"core","method":"GET","url":"/remote.php/dav/files/bb/save/StromVergleich2018.xlsx?c=ttt&x=64&y=64&forceIcon=0&preview=1","message":"unable to open image `/tmp/StromVergleich2018.pdf': No such file or directory @ error/blob.c/OpenBlob/2712"}
{"reqId":"W792cQUJIMQAAF6jU@AAAAAD","level":0,"time":"2018-10-11T16:12:33+00:00","remoteAddr":"XXX","user":"bb","app":"webdav","method":"GET","url":"/remote.php/dav/files/bb/save/StromVergleich2018.xlsx?c=ttt&x=64&y=64&forceIcon=0&preview=1","message":"Exception: HTTP/1.1 404 Not Found: {"Exception":"Sabre\DAV\Exception\NotFound","Message":"","Code":0,"Trace":"
#0 [internal function]: OCA\DAV\Files\PreviewPlugin->httpGet(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
#1 /owncloud/lib/composer/sabre/event/lib/EventEmitterTrait.php(105): call_user_func_array(Array, Array)
#2 /owncloud/lib/composer/sabre/dav/lib/DAV/Server.php(479): Sabre\Event\EventEmitter->emit('method:GET', Array)
#3 /owncloud/lib/composer/sabre/dav/lib/DAV/Server.php(254): Sabre\DAV\Server->invokeMethod(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
#4 /owncloud/apps/dav/lib/Server.php(298): Sabre\DAV\Server->exec()
#5 /owncloud/apps/dav/appinfo/v2/remote.php(31): OCA\DAV\Server->exec()
#6 /owncloud/remote.php(165): require_once('...')
#7 {main}","File":"/owncloud/apps/dav/lib/Files/PreviewPlugin.php","Line":115}"}

config_report_20181011.zip

@ownclouders
Copy link
Contributor

GitMate.io thinks the contributors most likely able to help are @ownclouders, and @PVince81.

Possibly related issues are #13824 (Delete File), #27274 (delete), #2472 (Delete Multiple files.), #1374 (shared files deleting issue), and #26837 (Delete file fails).

@micropurpose
Copy link
Author

micropurpose commented Oct 12, 2018

./lib/private/Preview/Office.php

on error and if $useFileDirectly the original office-file gets deleted (see line " \unlink($absPath);").

public function getThumbnail(File $file, $maxX, $maxY, $scalingUp) {
[..]
 $useFileDirectly = (!$file->isEncrypted() && !$file->isMounted());
  if ($useFileDirectly) {
                        $absPath = $file->getStorage()->getLocalFile($file->getInternalPath());
                } else {
                        $absPath = \OC::$server->getTempManager()->getTemporaryFile();
[...]

  //create imagick object from pdf
                $pdfPreview = null;
                try {
                        $pathInfo = \pathinfo($absPath);
                        $pdfPreview = $tmpDir . '/' . $pathInfo['filename'] . '.pdf';

                        $pdf = new \imagick($pdfPreview . '[0]');
                        $pdf->setImageFormat('jpg');
                } catch (\Exception $e) {
                        \unlink($absPath);
                        @\unlink($pdfPreview);
                        \OCP\Util::writeLog('core', $e->getmessage(), \OCP\Util::ERROR);
                        return false;
                }

fix:
\unlink($absPath); --> if (!$useFileDirectly) \unlink($absPath);

fix2:

LibreOffice needs a homedir, www-data has no homedir. this will cause the exception:

libreoffice --headless --nologo --nofirststartwizard --invisible --norestore --convert-to pdf [..]:
[Java framework] Error in function createSettingsDocument (elements.cxx).
javaldx failed!
Warning: failed to read path from javaldx

please see:
libreoffice-error

./lib/private/Preview/Office.php
private function initCmd() {
              $cmd = '';

              $libreOfficePath = \OC::$server->getConfig()->getSystemValue('preview_libreoffice_path', null);
              if (\is_string($libreOfficePath)) {
                      $cmd = $libreOfficePath;
              }

              $whichLibreOffice = \shell_exec('command -v libreoffice');
              if ($cmd === '' && !empty($whichLibreOffice)) {
                      $cmd = 'libreoffice';
              }

              $whichOpenOffice = \shell_exec('command -v openoffice');
              if ($cmd === '' && !empty($whichOpenOffice)) {
                      $cmd = 'openoffice';
              }

              if ($cmd === '') {
                      $cmd = null;
              }
              
              $tmpDir = \OC::$server->getTempManager()->getTempBaseDir();
              $this->cmd = "export HOME=".$tmpDir ." && ". $cmd;
      }

@PVince81 PVince81 added this to the backlog milestone Oct 12, 2018
@PVince81
Copy link
Contributor

thanks for spotting.

I thought the home dir thing was mentioned somewhere in the docs but didn't find it in config.sample.php.

The catch block behavior is definitely a bug.

To be scheduled for fixing in 10.0.11

@PVince81
Copy link
Contributor

PR here: #33232

I've decided to remove the line with unlink completely because the TempManager knows how to clean up such files anyway at the end of the PHP request

@lock lock bot locked as resolved and limited conversation to collaborators Oct 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants