Giter Site home page Giter Site logo

Comments (5)

juliushaertl avatar juliushaertl commented on September 25, 2024

Thanks for reporting. I would not expect the Nextcloud storage layers to truncated the file when the storage throws an out of quota exception but I might be wrong there. I'll check that on our side.

For the error, we can definitely report back such a case on the WOPI request. It actually would be good to know the size upfront to we do not even attempt to write larger files if they don't fit.

  • Check if Content-Length is already passed by Collabora and if we can validate it against the free space
  • Check why

Regarding reporting back we might need to agree on a response status and format to give back a custom error message as WOPI itself only defines some basic status codes and no format for a response body https://learn.microsoft.com/en-us/microsoft-365/cloud-storage-partner-program/rest/files/putfile#status-codes However I think error message hand over to also show something to the user would be nice in any failure case

from richdocuments.

juliushaertl avatar juliushaertl commented on September 25, 2024

We can check for the quota with something like this:

Server storage layer does not check the quota upfront as is just does a stream copy without being aware of the size.

diff --git a/lib/Controller/WopiController.php b/lib/Controller/WopiController.php
index a9cf99ac..5e31e318 100644
--- a/lib/Controller/WopiController.php
+++ b/lib/Controller/WopiController.php
@@ -70,6 +70,7 @@ use OCP\Share\IShare;
 use Psr\Container\ContainerExceptionInterface;
 use Psr\Container\NotFoundExceptionInterface;
 use Psr\Log\LoggerInterface;
+use Sabre\DAV\Exception\InsufficientStorage;

 class WopiController extends Controller {
        /** @var IRootFolder */
@@ -107,6 +108,7 @@ class WopiController extends Controller {

        // Signifies LOOL that document has been changed externally in this storage
        public const LOOL_STATUS_DOC_CHANGED = 1010;
+       public const LOOL_STATUS_NO_SPACE = 3000;

        public const WOPI_AVATAR_SIZE = 64;

@@ -506,6 +508,13 @@ class WopiController extends Controller {
                                }
                        }

+                       $size = $this->request->getHeader('Content-Length');
+
+                       if ($file->getParent()->getFreeSpace() < $size) {
+                               return new JSONResponse([
+                                       'LOOLStatusCode' => self::LOOL_STATUS_NO_SPACE,
+                               ]);
+                       }
                        $content = fopen('php://input', 'rb');

                        try {

from richdocuments.

juliushaertl avatar juliushaertl commented on September 25, 2024

@thebearon What do you think about adding a new status code for this in https://github.com/CollaboraOnline/online/blob/db31a486dfbf42669662b2b2d8db74bf99f881a0/wsd/Storage.hpp#L311 ?

We could actually extend this even further with a custom error message that Nextcloud could return, e.g. to indicate more clearly what to check in other error cases like of https://learn.microsoft.com/en-us/microsoft-365/cloud-storage-partner-program/rest/files/putfile#status-codes

from richdocuments.

juliushaertl avatar juliushaertl commented on September 25, 2024

@pedropintosilva Something we probably can discuss next week in our call, I think having a way to report the proper root cause back to the user within Collabora Online would be really benificial here to not just show a generic error if the save has failed.

from richdocuments.

juliushaertl avatar juliushaertl commented on September 25, 2024

Filed CollaboraOnline/online#8713 upstream for improved error reporting

from richdocuments.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.