-
Notifications
You must be signed in to change notification settings - Fork 669
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
Private links in share dialog and shell integrations #5763
Conversation
csync/src/csync_update.c
Outdated
@@ -494,6 +494,7 @@ static int _csync_detect_update(CSYNC *ctx, const char *file, | |||
st->etag = c_strdup(fs->etag); | |||
} | |||
csync_vio_set_file_id(st->file_id, fs->file_id); | |||
csync_vio_set_file_id(st->file_id_local, fs->file_id_local); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Man that was confusing.. :)
src/libsync/syncjournaldb.cpp
Outdated
// Populate the new column from fileid by using its structure: | ||
// fileid is %08d of the numeric id concatenated with the instanceid, | ||
// guaranteed for owncloud servers <= 10.0.0 | ||
query.prepare("UPDATE metadata SET fileidlocal = CAST(CAST(SUBSTR(fileid,1,8) as INTEGER) as TEXT);"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yay for doing this in SQL :)
Would you have a way to autotest the migration step? Maybe in tx.pl or so? |
FYI @PVince81 @DeepDiver1975 to keep you in the loop |
Code wise it looks good. I just wonder how decoupled this can be. Could we merge this PR here and just schedule something for the server? |
@guruz Will look at tests. The idea for decoupling id/fileid would be that we check for the presence of the new fileid header, and use left(8) of the full id if the new header isn't present. That way it works for old servers and future servers can have completely different id/fileid. |
src/libsync/owncloudpropagator.cpp
Outdated
@@ -323,6 +323,27 @@ bool PropagateItemJob::checkForProblemsWithShared(int httpStatusCode, const QStr | |||
return false; | |||
} | |||
|
|||
void PropagateItemJob::readFileIdHeaders(const QNetworkReply &reply) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any special reason to use reference for a qobject which was on heap before? (i don't think we do that anywhere else in the client)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I did this automatically because it can't be 0. But yes, it's not the style we use and will adjust it.
src/libsync/propagateremotemkdir.cpp
Outdated
@@ -127,6 +126,10 @@ void PropagateRemoteMkdir::propfindResult(const QVariantMap &result) | |||
} | |||
if (result.contains("id")) { | |||
_item->_fileId = result["id"].toByteArray(); | |||
_item->_fileIdLocal = result["fileid"].toByteArray(); | |||
if (_item->_fileIdLocal.isEmpty()) { | |||
_item->_fileIdLocal = _item->_fileId.left(8); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should all the .left(8) magic (it's in other commits too right?) be moved to a function that has a fat comment to remove the whole stuff in a year or two?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had it in a function, but then removed it when there was only a single use left. Then I later found this corner case (PropFind is only sent for servers <= 7.0.0). Yep, will put it into a function again.
src/libsync/propagateuploadng.cpp
Outdated
QByteArray fid = job->reply()->rawHeader("OC-FileID"); | ||
if(fid.isEmpty()) { | ||
qWarning() << "Server did not return a OC-FileID" << _item->_file; | ||
if(job->reply()->rawHeader(fileIdHeaderC).isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we assume that (future) servers will continue to always emit both "local" and full IDs?
@PVince81
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The client at least needs both for now.
a9d6cf1
to
e2c7305
Compare
Rebased now that the logging PR was merged. |
src/gui/owncloudgui.h
Outdated
* Open a share dialog for a file or folder. | ||
* | ||
* sharePath is the full remote path to the item, | ||
* localPath is the absolute local local path to it (so not relative |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How local is the local path? "local local" ;)
@guruz This looks good to me now |
Users of the 'id' property would like to be able to deduce the 'fileid' property from it. To allow that the 'id' property is now required to be made up from two parts: a purely numeric one, plus one that starts with a letter. The first part shall be the (potentially padded) fileid. The background is that clients need the fileid to be able to create private link urls, but they currently only have the full 'id' property available. See owncloud/client#5763
@guruz @davivel To move this forward I've created this PR against core: owncloud/core#28193 - ideally we can drop the discovery and storage of the short numeric ids. |
It existed to work around a Qt bug that has been fixed https://bugreports.qt.io/browse/QTBUG-48953 owncloud#3300
I've updated this PR to remove the fileid discovery and storage and instead generate the fileid from the id we store already! From my point of view this is ready to merge. Note: Since I rebase-dropped a bunch of unnecessary commits now, the remainder doesn't compile individually anymore. Let me flatten and merge this once it is approved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed a few commits to refactor and make the branch work on macOS and Windows, feel free to rebase, squash (like the build fixes) or edit commits. Feel free to give feedback on those and I can fix them too.
To be able to fix an issue on Windows I added GET_STRINGS:BEGIN
and GET_STRINGS:END
messages, the linux code might have to be adjusted.
src/gui/socketapi.cpp
Outdated
{ "APPNAME", Theme::instance()->appNameGUI() }, | ||
{ "CONTEXT_MENU_TITLE", Theme::instance()->appNameGUI() }, | ||
{ "COPY_PRIVATE_LINK_TITLE", tr("Copy private link to clipboard") }, | ||
{ "EMAIL_PRIVATE_LINK_TITLE", tr("Send private link by email...") }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I also name variables to match those, it would be nice if the _MENU_TITLE
suffix was consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed!
src/gui/socketapi.cpp
Outdated
{ | ||
static std::array<std::pair<const char *, QString>, 5> strings { { | ||
{ "SHARE_MENU_TITLE", tr("Share with %1...", "parameter is ownCloud").arg(Theme::instance()->appNameGUI()) }, | ||
{ "APPNAME", Theme::instance()->appNameGUI() }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this string going to be used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not right now, it seemed like a string we might need - can drop for now.
src/gui/socketapi.cpp
Outdated
void SocketApi::command_GET_STRINGS(const QString &, SocketListener *listener) | ||
{ | ||
static auto map = std::initializer_list<std::pair<const char *, QString>>{ | ||
{ "SHARE_MENU_TITLE", tr("Share with %1...", "parameter is ownCloud").arg(Theme::instance()->appNameGUI()) }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
@SamuAlfageme The contents should now also be in |
@jturcotte I think I have addressed the remaining issues and tests look good (dolphin only tomorrow though). @SamuAlfageme I also updated the local_links branch in the main client repo in case you want to test early. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went through the changes again and everything looks good. If you can also go through my commits I guess it's legal that I approve this PR.
|
||
# Currently 'sharable' also controls access to private link actions, | ||
# and we definitely don't want to show them for IGNORED. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: 'sharable' -> 'shareable'
Merged manually, squashing various review and fixup commits together. |
This is an initial draft for comment.
Mostly the patch is quite straightforward. The exception is that storing the fileid in addition to the id adds some complications, see 875b9bb . In particular
.left(8)
, we might as well not add the new column and just do that whereever needed.The other option would be to have a transition plan where the server also replies with a new
OC-FileIdLocal: <oc:fileid>
header. Then oc:id and oc:fileid would be truly decoupled.Opinions?
The last thing is that of course the OSX and Windows integrations also need to be updated to include the new action. Note that while I only added one action to the context menu for now, we might desire more, see discussion in #5023.
(I wonder whether we should generalize and have the socket api give a list of context menu commands and menu titles to the integrations - similar to GET_STRINGS - then we could adjust context menus without touching the integrations in the future)