Commit graph

309 commits

Author SHA1 Message Date
Ashod Nakashian
08061da286 wsd: faster save and exit when unloading
Change-Id: Ic99739867c3e9529bf0369388700398eb178265c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-25 07:54:11 -05:00
Ashod Nakashian
948e8d5202 wsd: do not skip uploading when last save skipped
When the document isn't modified and we save,
we get back "unmodified" failure from Core.
This has the unwanted side-effect of skipping
uploading.

As we now decide whether to upload or not
based on the file timestamp on disk,
this logic has no purpose and in fact can
cause a lot of grief.

Removing this outdated logic has the nice
side-effect of simplifying the code, as
the save result doesn't need to be propagated.

Also, save failures are now communicated to
clients at the point of handling the save
response, not when uploading (which is
a distinct stage). And upload failures
are reported separately.

Change-Id: Ia465a0069280fb6bea47e413f0d885565f0bbb3d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-25 07:54:11 -05:00
Ashod Nakashian
3c953faded wsd: send the client 'docunloading' for all unloading cases
And don't load documents when the ShutdownRequestedFlag
is set, not just the TerminationFlag.

Change-Id: I94c720d6fd7c361549bc905e093886619e8f188b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-25 07:54:11 -05:00
Ashod Nakashian
d0597288dc wsd: stop if unloading and have no sessions to upload
It is possible to lose the last writable session
during unloading and get stuck forever.

This can happen in the following scenario (as observed
in a rare test run):

1. always_save_on_exit is true.
2. The last/only writable session disconnects.
3. We save and upload.
4. We attempt to stop because the clients have disconnected,
   but because we are uploading, it doesn't flag to stop.
5. Uploading fails repeatedly until we reach the limit.
6. We endlessly check to save and upload and even though
   there is nothing to save, we couldn't even check for
   the need to upload, getting stuck.

With this patch the above scenario is not possible.

Change-Id: I19e7b621f2b452a9f18964f5f19d6eb378a48797
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-25 07:54:11 -05:00
Ashod Nakashian
bef9c3ff65 wsd: dump all the state managers in DocBroker
This adds dumpState to DocumentState, SaveManager,
and StorageManager classes, and dumps all the
missing members.

Also, normalize the format and make it symmetric
and consistent.

Change-Id: Ie0cc8e07d13de60c33d64cd621abf4e815a4ef94
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-24 07:38:13 -05:00
Ashod Nakashian
6c2fe26e3f wsd: count save and upload failures
Change-Id: Ifaae1fb1f28e7c25b359fff313b570c9ed8cf224
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-09 19:35:19 -05:00
Ashod Nakashian
d8c2578ec4 wsd: detect storage conflict with no clients
When the last client connection is closed,
there is UI (or user) to provide input
on the document conflict dialog. In this
case, we detect that the situation is final
and unresolvable and we simply give up.

We log a warning and dump the document state
before terminating.

Change-Id: I111a446b8743a0d16b7ed8b39751a419036c927f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-08 20:46:01 -05:00
Ashod Nakashian
9702cce25f wsd: preserve the original modified time as string
We no store the origina modified time of the document
as we receive from the storage server in string
form and send it back as-is. This avoids any
potential issues with the roundtrip of conversion
to and from a timestamp.

Change-Id: I524bea8f36c3ce62dcd00c4fe6a1e7e083287ed1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-08 08:05:39 -05:00
Ashod Nakashian
7757989795 wsd: save -> upload
Probably the last remaining incorrectly labelled
helper that checks for in-progress uploads, but
had retained the old and misleading label of 'save'.

Change-Id: I693275b1559f3dae4e9e3ab2408d997f56ff86e3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-04 10:26:49 -05:00
Ashod Nakashian
acbfc41afd wsd: remove unused resetUnloadRequested
Change-Id: Icb9ef1c02a9b8d31add5b305c3c1d09d3e251337
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-04 10:26:49 -05:00
Ashod Nakashian
9e5b9d6d37 wsd: support PDF comment saving during unload with test
PDFs are view_comment type documents where
editing is not supported, but adding comments
are. This means that we do get ModifiedStatus=true
but we never get ModifiedStatus=false after
.uno:Save. This is because the save command is
handled in a special way in Core by invoking
save-as instead, which doesn't reset the
ModifiedStatus.

The issue with this was that DocBroker was
stuck on trying to save the document
before unloading, thinking it was modified
due to the stuck ModifiedStatus. Here,
we change the definition of isPossiblyModified()
to ignore the ModifiedStatus for such documents.
Instead, we rely on the last save being successful
and that no new user input exists past the last
save request.

In addition, we now have a new Cypress test
that reproduced the failure without the fix
and now passes with the fix.

Change-Id: Ida9d486ac93a588b9007c5e4583d8bf3c090a62d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-01-26 15:33:15 +05:30
Ashod Nakashian
feb01facfa wsd: do not count disconnecting sessions as active
This fixes failures in UnitCopyPaste and
TileCacheTests::testWireIDFilteringOnWSDSide where
the documents are closed while isModified() is true.

Change-Id: I6de683530df9b7987ad87897e9ce70b5fc3d3a15
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 65105263fbed89d787ac59ca77f64896bacf6832)
2022-01-11 09:28:03 +01:00
Ashod Nakashian
036bc60c24 wsd: save and wait until document isn't modified
We make sure that we always check for last-minute
modifications before stopping DocBroker. This covers
the cases where there are modifications that we need
to save and/or saved data that needs uploading.

This save, upload, and stop logic is now in a helper
that cleanly handles this exit-time check.

Change-Id: Ibee0e7769a396b205de955f26700ebcb27d5ac95
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 69f9d86c8b8a477b5a0cf1910eb1b7498eaceeac)
2022-01-11 09:28:03 +01:00
Andras Timar
f07ff8c7e0 rename: remaining lool->cool changes
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: Ib7d4e804bebe52dead8d53b0e0bbaed0f08bf3d0
2021-11-18 14:14:11 +01:00
Ashod Nakashian
6f25a9e8ee wsd: move getDocKey into RequestDetails
RequestDetails manages URLs and their components.
The DocKey is based on the URL, so it makes sense
to be provided by RequestDetails.

Change-Id: If99e677a2e5a227f09b5035f388c4da587084db9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-11-02 08:43:26 -04:00
Ashod Nakashian
0933508fb8 wsd: move sanitizeURI into RequestDetails
And cleanup around DocKey and URI handling.

Change-Id: Ieef83197ac9b04e22af92eee217e336bc2b31761
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-11-02 08:43:26 -04:00
Ashod Nakashian
6dec522a65 wsd: sanitizeURI from to RequestDetails
Change-Id: I8693bd6a36be4c67b62be4b5a997dd227460fbd1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-09-26 17:02:01 -04:00
Ashod Nakashian
b82b18e8c9 wsd: autosave using the last editing session
Change-Id: I556b7b49b2d1abc0e61ea7ecaa8e5f9406c408f3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit b3738719a3b7301688faecfd721a97180eab0020)
2021-09-26 17:02:01 -04:00
Ashod Nakashian
c4fb58df61 wsd: allow new views while unloading
Unloading duration depends on the time to save
and upload the document, during which a new view
might be opened. We now allow aborting the unloading
and resume reusing the document as-is.

Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 8f299eb2cdfe0ef869a8c90fbc602a93ba2fcb73)

Change-Id: I7bc485177929c0d1c9ef12b02672db493ac402c9
2021-09-26 17:02:01 -04:00
Tomaž Vajngerl
b31eb2ab92 New POST service to render a search result + unit and integ. tests
This adds a new service render-search-result, which renders an
image of the position where, the search fund a hit. The search
result contains the information in which object or paragraph,
which is just the node id and node type from the document model.

The service takes the document and the search result (xml file)
as the input and returns a PNG image as the output.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>

Change-Id: Iffc158c5b0a3c9a63f8d05830314c9bc1616b3b1
Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
2021-09-13 10:36:15 +02:00
Szymon Kłos
27e95bbe7e Wait for async save result on DocumentBroker stop
When async save was started but we want to stop DocumentBroker
- we shouldn't kill the socket which listens to save result.
Because when we kill socket we will destroy DocumentBroker
before saving is completed, this allows for a minimal time
to connect again to the document and receive old content
from the WOPI storage. When we wait for async save result
we will keep DocumentBroker alive and next session can be
connected and receive correct content.

fixes: https://github.com/CollaboraOnline/online/issues/2747

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I5505a5ccc1f3d6928c723bddfea16bf5c5798d1e
2021-07-28 13:00:45 +02:00
merttumer
9137ed9dfa Broadcast save-as to other views
We ask for save as for the plain/text type documents
such as csv or txt. Notify other views about it so
they can follow one to the new document

Signed-off-by: merttumer <mert.tumer@collabora.com>
Change-Id: I4cdcec6148d1064ad4e90ad9be2ce483c19a8eda
2021-07-06 12:38:48 +03:00
Ashod Nakashian
7963317e7c wsd: un/block the UI during renaming
Change-Id: I2dfa18f2885369c089e326a6a010f084da0897b1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
14c17fb07a wsd: postpone autosave
Change-Id: I83d0110d5c216a8063da54618e059e66311e7054
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
d4e60da934 wsd: support uploading after loading from a template
Templates are special because the file that gets
loaded is not in the same format as the final one.
An implicit save-as is issued in Kit for template
loads right after loading to create the final
document format. It is this file (as opposed to the
template) that needs to be uploaded, which we do
right after we get the 'status:' message in
DocBroker to actually create the first version
in storage.

Change-Id: I23cbf527f1059b0b4059f15069737ab35ac860e7
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
cbf05e0eff wsd: handle renameFile command with async uploading
The client always issued a save before renameFile.
This worked fine until we make uploading asynchronous.

Now that uploading is done asychronously, the renameFile
command arrives while uploading is still in progress
and fails because renaming is done via the same
storage API used for uploading.

It is best to do both the saving (including uploading)
and renaming directly in WSD, instead of relying on
the client to save explicitly before renaming.

Change-Id: I99f6294f4c83130bc13ec8e3b013ba0192f0f84c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
cbee71a6da wsd: track user issued activities on the document
Some user-initiated activities, such as renaming
the document filename, is either a multi-stage
activity or involves async operations.

Using a new Activity enum in DocumentState, we
now track each of the different activities that
needs special attention or handling.

Change-Id: I9cd2d04b10a97387ce02f5c3cc98b41a1732af6a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
16a3c43871 wsd: stop after successfully uploading
With async uploading we have to process the
stop-condition only after we get the response from
the async operation. For now, we don't stop
if we fail to upload, giving a chance to retrying.

Timeout should be used in the poll loop to
limit how long we retry.

Change-Id: I8e8f8618f92f34ef2f1853e499f4f8d6ce932b40
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
35bf4a32ed wsd: DocumentBroker::needToUploadToStorage now returns an enum
This is to also include the 'force' case that is
needed when unloading a document.

Now that the force flag is reliably set, we don't
need to override it in needToUploadToStorage.

Change-Id: Ic0672e6c7bcb53a17ec6a0cbd2d2f8b434fbc300
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
161cf090e2 wsd: upload after saving only if necessary
Change-Id: I4037030329815a87edf8e15d151dbec2491e9973
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
39bb098601 wsd: support asynchronous upload requests to storage
Add the necessary support for handling async
document upload to storage in DocumentBroker.

Change-Id: Id7a58c245d729cef58669bafb60db450f7ebbba2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
9e501acb25 wsd: remove unused DocumentBroker member
Change-Id: Id39d8f2c9ac6d0ba9cc042d3c2dd12794a640ddb
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-13 21:57:43 -04:00
Ashod Nakashian
c6f7e3758f wsd: typo
Change-Id: I0b9e17c1963636855a3360df57747dec8f9e4aa2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-13 21:57:43 -04:00
Tor Lillqvist
809c78480d The convention is to call the processes 'WSD', 'ForKit', and 'Kit'
I.e., not in upper case. I was misunderstanding.

Change-Id: I3275446cba0eb954b5ef398d3406d0543c2fb7e7
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-25 10:41:11 +03:00
Ashod Nakashian
e9cf4681a2 wsd: move TerminatingPoll to Socket.hpp
Makes it accessible to more code.

Change-Id: I73dd1895defe47ae40873b6155203768055206ec
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-13 16:44:09 -05:00
Henry Castro
cedf950a52 wsd: add interactive state
Add a new state before load the document,
when Macro Security dialog popup, and avoid
to send the event load timeout.

Change-Id: I5973c5205e90e5447e5478cbab895709a68606f6
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-03-03 09:18:15 -05:00
Ashod Nakashian
f24aec95e2 wsd: reuse RequestManager in SaveManager
Change-Id: Ic1842d126edeb8e8771998466aba79598e741a68
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-21 13:07:05 -05:00
Ashod Nakashian
3431a68709 wsd: simplify, comment, and organize RequestManager
Change-Id: I92d19bb0e0d13ae2c1683e5703924dbd87d47d2f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-21 13:07:05 -05:00
Ashod Nakashian
f056d2be01 wsd: set the result of saving and mark the response time
Change-Id: Ia31376c38b4bad3dc15f618c902258af9b8f81f2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-20 16:47:17 -05:00
Ashod Nakashian
26d0d48b4c wsd: wopiLoadDuration -> wopiDownloadDuration
Consistent with names elsewhere and less confusing.

Change-Id: Ia72cdef0f6d6cd9589ce54028472e10008cf882c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-18 11:08:38 -05:00
Ashod Nakashian
a350dad19b wsd: Save -> Upload in StorageManager
We use download/upload in the storage
and load/save elsewhere, to avoid confusion.

This renames 'save' to 'upload' in the storage
for consistency.

Change-Id: I9ac991c2b52e2586b97c58db02110ff04bfd17d3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-15 09:54:41 -05:00
Ashod Nakashian
725f19ab4d wsd: encapsulate common request members
Instead of inheritance we use composition
to preserve the uniqueness of the members
of SaveManager and StorageManager.

Change-Id: Ifad82787e54089d49226085e009ade67bfc7938a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
0a8eaff48b wsd: track the timestamp of the uploaded file
This will be used to detect whether we need
to upload the document or not.

Change-Id: I2c5f6d058b1a8e0a6ab20c9561b6701413fb5878
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
e5d33a7f3e wsd: lift lastStorageUploadSuccessful into RequestManagerBase
Change-Id: I06eba0b539ecc0586be3aea178120f23762229d3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
8046de6146 wsd: lift ModifiedTime into RequestManager
Change-Id: Id02f7ba58e96b6b93d38cfe8f15c74ce2553517d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
4282f5b10a wsd: introduce RequestManager
This is to encapsulate and track the
common logic between SaveManager and
StorageManager.

Change-Id: I0c5a59edb8a26b258ba66d65983e2f76198ecbc9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
8035c99f3b wsd: move lastSaveTime into StorageManager
Change-Id: I74f4bdf00e94a7010ff8f7a9389613beedb64fad
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
92487cfa5d move lastStorageUploadSuccessful into StorageManager
Change-Id: I33a64b9bbb596bcd819adbfd5d7dcee0180bb5fb
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
6bfbcf7a5f wsd: move documentLastModifiedTime into StorageManager
Change-Id: Ib33e5d142ce59b8d57177b1fd91cc309063a2d59
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
4fc574e539 wsd: introduce StorageManager
This is to encapsulate and track the logic
for uploading documents from the Storage.

Change-Id: I5b972151fe9548526755d18063d37cc95949e68f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
55b49a3c14 wsd: separate save handling from save-as and rename
We should only update the save timestamps when we
really save a new version of the document.

Requesting renaming or moving ("save as") in storage
should not be confused with actually saving in Core.

Here we take the first step in this separation,
and we only update the last save response time
when we truely get a response from Core, and
not when we execute a document path/name in storage.

Change-Id: I931c62b306dd3b4906a9e910f844a35fb3f4b6f0
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
d8cddcea06 wsd: lastFileModifiedTime -> modifiedTime
The SaveManager is responsible for the file on disk.

Change-Id: I92f7843375fdc875bc7d1af3fba387f67a4f0ca5
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
d806353af1 wsd: move lastFileModifiedTime into SaveManager
Change-Id: Ic3dd4f193e1676a47288bc77e75f6643438bafc7
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
76be0d562b wsd: move save tracking into SaveManager
Change-Id: Ic98cc50469f1e25bb2e007554e1d9d42e020dc91
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
ea96f43df9 wsd: introduce SaveManager
The SaveManager is responsible for the document's
save state. It also encapsulates the members
necessary to track the save state and related
data.

Change-Id: I3ed0f1d93f25988b1ad8b1a121a2080288866a53
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-13 13:25:36 -05:00
Ashod Nakashian
8a37738fdb wsd: documentation of DocumentBroker states
This details the design of the DocumentBroker
states and state-machines as they are to be
eventually implemented. Not everything described
is current, but the goal is to document what
the design ought to be, not what it is.

Change-Id: I938177812777af058b46c41a396407d0a083cbc4
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-31 22:20:59 -05:00
Ashod Nakashian
523cfec790 wsd: save -> upload
Change-Id: I08445bd9f726225809c443f4bdfc611bbfc03bf6
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-31 22:20:59 -05:00
Ashod Nakashian
30f7ea2e9a wsd: remove default arguments of uploadToStorageInternal
Only the last argument (force) was implicit, and only
in one call (of total two calls). Explicit is better.

Change-Id: Ic26f4dd265f48156d1730f1b95bb70145ca47873
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-31 22:20:59 -05:00
Ashod Nakashian
2b96bf3fd6 wsd: move the loaded flag into DocumentStatus
The loaded flag is used to track whether or not
the document was ever loaded. It does *not* reflect
whether or not the document is currently loaded,
rather it is used to save the document, if necessary,
before unloaded.

This is why we need to track it as a separate boolean,
rather than implicitly tracking this state via the
DocumentState enum, which would not be able to
differentiate between a failed-to-load state and
one of a normal end-of-life, after loading.

Change-Id: I1fc3fb09c31cadf7ebb6b0123e462e78dd0af356
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-29 09:22:36 -05:00
Ashod Nakashian
048c468caa wsd: move the markToDestroy flag into DocumentStatus
The markToDestroy flag tracks whether or not the
document is in the process of being unloaded.

Change-Id: I8f2339f75ed6d7c5d318eb1d467d6a9cbc1d61c2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-29 09:22:36 -05:00
Ashod Nakashian
1041346928 wsd: move the closeRequested flag into DocumentStatus
The closeRequested flag tracks owner termination.

Change-Id: I91d7491396cd8db6ca493ba8015a5310c361a2f3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-29 09:22:36 -05:00
Ashod Nakashian
ca0c2a24cc wsd: introduce DocumentState class
DocumentState is responsible for tracking
the state of the document, properly documenting
the different stages of the document lifetime
and encapsulating all the relevant members.

DocumentState is still unused in this commit.

Change-Id: Ic2c8de3a9f2d42c5550c5f4ad5f889040f697890
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-29 09:22:36 -05:00
Ashod Nakashian
b4dd9f82a3 wsd: saveToStorageInternal -> uploadToStorageInternal
Change-Id: I0273314d65ebee91092a883bebeb53ab31051194
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-26 21:40:59 -05:00
Ashod Nakashian
f14034584f wsd: saveAsToStroage -> uploadAsToStorage
Change-Id: I6edbff6da6b2c29000c0a66524266138aeb88b89
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-26 21:40:59 -05:00
Ashod Nakashian
ed1e08662a wsd: saveToStorage -> uploadToStorage
Change-Id: Ie00728ca81d481676ae3a3c44d8d79e80ee29278
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-26 21:40:59 -05:00
Ashod Nakashian
a176213750 wsd: lastStorageSaveSuccessful -> lastStorageUploadSuccessful
Change-Id: I71618e388f44ac7b74f295c8af5d0235b395fe87
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-26 21:40:59 -05:00
Ashod Nakashian
7a9dc03e46 wsd: DocumentBroker documentation
Change-Id: Iaacb2bb961719e23ef0e955587d70f38ef5ce464
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-26 21:40:59 -05:00
Ashod Nakashian
f038204021 wsd: load -> download
To differentiate between the different stages
of document lifecycle, fetching documents
from the storage is now called 'download',
as opposed to the previous 'load', which is
reserved to loading document in Core.

This is a cosmetic renaming to avoid
confusing usage and intent going forward.

Change-Id: Ib9451e6f73bab19b877a3e6c8fb5b17ba82a06ab
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-01-23 23:55:43 +00:00
Ashod Nakashian
8298fdb2d6 wsd: cosmetic and consts
Change-Id: Ibb4bb7c527f68786bd6288b407008a3e3a7b2e17
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-09 17:19:58 +01:00
Ashod Nakashian
a76375234d wsd: remove unsused return values
Saving documents to storage also logs and broadcasts
the result to the users. Return values from these
functions are ignored, and anyway not actionable.

Change-Id: Iaf0dab9c6ac8c593e4df292c71fcb30e8b6d7eeb
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-09 17:19:58 +01:00
Ashod Nakashian
90f79998fb wsd: convert limitLifeSeconds from int to chrono
No advantage in using int when chrono handles
conversion and comparisons transparently for us.

Change-Id: Idc942e7a2557ef979d876f378cf6bb84d3e657cd
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-08 09:26:41 +00:00
Gökay Şatır
b51413c0a0 Admin console: Cosmetic changes and documentation.
Change-Id: I977b5bc56f44c44b8bedf9f9bd710e7050fe67ff
Signed-off-by: Gökay Şatır <gokaysatir@collabora.com>
2020-12-07 17:30:51 -05:00
Gökay Şatır
ace1c23a99 Admin console log levels.
Now chosen log level is propagated to forkit and kits.
Also, admin console users can filter logs according to their channel names on client side.

Change-Id: Ife15a6148ed87533b81e9d63da252c633e74e559
Signed-off-by: Gökay Şatır <gokaysatir@collabora.com>
2020-12-07 17:30:51 -05:00
Michael Meeks
c069f72c4d Socket - re-work disposition to ensure we transfer sockets.
A number of call-sites, eg. clipboard, or admin-ws were
writing to sockets assuming they could return all the data
in a single series of writes, without needing to poll. As
such they failed to addSocketToPoll on the new poll - eg.
the docBroker. Unfortunately this meant that on EAGAIN
writes, the socket would be closed and the last parts
of a message lost.

Browsers would give net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK)

The situation is/was intermittent, so painful to debug.
On under-loaded developer machines, socket buffers are larger,
so this was seldom seen.

The re-factor forces a transfer to another SocketPoll via
the disposition, except for a couple of corner cases.

Change-Id: I2f1b2f99f179c4fda84464c9241fe434fa527725
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2020-12-07 14:32:43 +00:00
Ashod Nakashian
0704514730 wsd: label storage operations as upload and download
Using "load" and "save" in the storage was a poor
choice of verbs, in hindsight, because these very
same verbs are also used to describe the loading
and saving of documents in Core.

It is more appropriate to label the storage
operations as download and upload, respectively,
to avoid any confusion. This is especially useful
because when reporting we have for some time now
been reporting the results of each of these
stages separately, there is no longer reason
to label them the same.

We already used "upload" and "download" in
some of the logs, but not all.

Change-Id: I0fac9130032e2c3c6dfb4d671c31130265091f0d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-30 18:46:46 -05:00
Ashod Nakashian
3f2ae319c9 wsd: make session in the upload details weak_ptr
Change-Id: I9e25526333977ada276f59f2e7e33a20dd27f924
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-30 18:46:46 -05:00
Ashod Nakashian
4162803e64 wsd: extract storage saving reponse handling
This is in preparation for asynchronous uploading.

Change-Id: I5c9977107b415efd24cbd99c29599b86cfe32933
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-30 18:46:46 -05:00
Ashod Nakashian
0d3a8f77d3 wsd: session is optional to broadcasting doc modification time
The current session is needed only while loading, as it's not
yet in the sessions container. But while saving, broadcasting
to all sessions includes the current session as well, and
we avoid sending duplicate message to the current session.

We also make the broadcast helper a member of DocumentBroker
which simplifies it.

Change-Id: I3bb37cc808d97ba2b772b88474a8c10f7fdff6b7
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-30 18:46:46 -05:00
Ashod Nakashian
fad4222a2a wsd: move convert-to docs into the jail
We now download the convert-to files into the
child-root/tmp directory and then move it into
the jail that will convert it. This way ownership
and cleanup become contained within our child-root
and jail subsystems. This reduces the chances of
leaking convert-to files and simplifies the design.

In addition, we avoid an extra file copy and improve
the security of the convert-to API.

Change-Id: I450c24d0d0dc0da447c8072b0701c3b48d07c81b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-23 21:29:34 -05:00
Ashod Nakashian
cb4beaca34 wsd: avoid the using keyword and use C++ size_t
size_t in C and in C++ are not necessarily the same
type. The C++ size_t is in the std namespace. Since
we do include many C headers, and indeed some C++
runtime headers do define size_t for backwards
compatibility, it's easy to mix and match the two
types.

Also, 'using std::size_t;' isn't a great practice,
so removed.

This is not exhaustive, just some low-hanging cases.

Change-Id: I85a36b6fd1acd204274b1869de9bcb94c8b3cf13
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-15 15:41:41 -05:00
Michael Meeks
0d10c2cae8 Set normalized view id for broadcast (ie. slide preview) thumbnails.
Change-Id: Ica5312ae9c7147c8dc969523e28d460348ba2e76
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2020-11-14 19:54:56 +03:00
Ashod Nakashian
8f2ded18da wsd: misc minor cleanup
Change-Id: I39911e6a6b16661173ae69e39d353e517857f282
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-02 07:56:03 -05:00
Ashod Nakashian
c71998438d wsd: document forced storage saving and remove default args
Change-Id: Ic7fde18f07dfe848e219b4ebba30426277ae1287
2020-10-22 14:40:40 +02:00
Andras Timar
0002fdfd6c fix license headers
Change-Id: I8623770b32d278a45357dc7f757fabfadd2b4af7
2020-10-01 11:56:43 +02:00
Szymon Kłos
70827c372c Simplify download process
Use hash to identify download and pass that to the client.
This allows us to reduce parameters for download requests.
DocBroker maps download ids to URL in the file system.

Change-Id: I254d4f0ccaf3cff9f038a817c8162510ae228bc5
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/101992
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-09-07 15:00:20 +02:00
Samuel Mehrbrodt
8c602e179e Revert "Revert "Don't update modified status after saving to storage fails""
This reverts commit e83e36bd9b.

Unit test failure was fixed

Change-Id: I2176368278725c1711df3b23eef95de6526c68d5
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100859
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2020-08-24 14:34:10 +02:00
Tamás Zolnai
e83e36bd9b Revert "Don't update modified status after saving to storage fails"
The reverted change breaks unit-wopi-documentconflict test.

This reverts commit 494a5221f5.

Change-Id: I3e89a6e6526e9388e4dc6a1ea8f8d8832e8cb169
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100678
Tested-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
2020-08-13 17:35:02 +02:00
Samuel Mehrbrodt
494a5221f5 Don't update modified status after saving to storage fails
Otherwise client gets a notification that document is unmodified.
This should not happen, as the document in the storage has not been updated
and so it should be considered as modified until saving to storage succeeds.

Change-Id: I6918f97d96a546ce086f622854f4cbeed48d54ae
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100162
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2020-08-13 09:39:30 +02:00
Mike Kaganski
a1fafe27f4 Allow user to try to lock the document for edit
Use mobile-edit-button for that is permitted.

Change-Id: I4d4c3f21d574abae033bacc69def96aaf6b51567
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98786
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2020-07-20 15:49:09 +02:00
Ashod Nakashian
aba09e165b wsd: improved TileCache
* Excised TileCacheDesc to improve performance and simplify code.
* clang-tidy suggestions and auto-rewrite fixes.
* Const-correctness.
* Inlined and improved a couple of trivial functions (that are called
often).
* Reduced some logs from INF to DBG as they are only meaningful to devs.

Change-Id: I1c4eb8c63da49aa061afbf3eb68cae23d4d5e7f3
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98661
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Tested-by: Jenkins
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-07-14 15:35:20 +02:00
Samuel Mehrbrodt
9f8fdb7bd7 tdf#131123 Report back real save result
665b1629de was not correct, as it reported back
the save result of the internal save (which usually succeeds).
Instead we want to know the save result of the remote storage (WOPI/Webdav).
So report that back instead.

Change-Id: Iaaa42b8c817a19c2c77935a6f81c1951fdf2216c
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97637
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2020-07-01 17:57:53 +02:00
Tor Lillqvist
7f25109f72 tdf#128502: Chunk of work to enable "multi-tasking" in the iOS app
Seems to not cause any serious regressions in the iOS app or in "make
run", but of course I am not able to run a comprehensive check of all
functionality.

Change-Id: I44a0e8d60bdbc0a885db88475961575c5e95ce88
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93037
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
2020-06-26 13:09:51 +02:00
Ashod Nakashian
17044ade27 wsd: fix: call to virtual function during destruction
Change-Id: I914025fe642f6c78d4a5731fdb8e8920a62838b1
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96379
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
2020-06-23 06:42:53 +02:00
Michael Meeks
99d6282dde Proxy: re-arrange URL structure & document it better.
Also implement 'close' during browser unload.

Change-Id: Ie2072c14cf863876c633b3371b86016367ad4992
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/94089
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-05-13 00:53:36 +02:00
Michael Meeks
34fc7fb6b7 Proxy: move requestDetails closer to ProxyProtocol.
Change-Id: I07c00ea1dad15fd70b658a04f722cbd516fd5c18
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/94088
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-05-13 00:53:24 +02:00
Michael Meeks
18c4301a1f Proxy: re-factor proxy handling into ServerURL and cleanup copy/paste.
Also adds ServiceRoot handling for clipboard.

Change-Id: I7bc6591130fcc7d693e59ab8561fb9e99f4e93d5
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93578
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-05-06 23:12:12 +02:00
Jan Holesovsky
8325deaf22 nocaps: Make the convert-to work too.
And also compile out ConvertToBroker in mobile apps, it is not
needed there, otherwise it wouldn't compile due to the added check for
nocaps.

Change-Id: I20fe7e3b702e4a1782640a2d0e71a40b1517beb6
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93510
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
2020-05-05 22:56:55 +02:00
Michael Meeks
92eff552a5 Lower convert-to process priorities by default.
Interactive / editing processes should take precedence over batch
thumbnailing processes to keep responsiveness good.

Change-Id: Ib100409e312cb2ca545586a734711a31a92f110c
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93323
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-05-02 22:03:36 +02:00
Pranam Lashkari
8b349716eb killpoco: removed Poco::Process completely
Change-Id: Iba67abf9342c11517c69c1d94903bf4752aa87d6
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/83770
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
2020-04-29 14:27:54 +02:00
Andras Timar
33000dfded typo fixes in comments and code
Change-Id: I6f31e050aab701e31064e1abc9429dce0a50c279
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92953
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
2020-04-26 23:19:52 +02:00