mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Merge pull request #4169 from owncloud/2.1_file_exists_before_share
[Sharing] Make sure the file is actually synced to the server
This commit is contained in:
commit
451ebd447b
@ -378,12 +378,23 @@ void SocketApi::command_SHARE(const QString& localFile, QIODevice* socket)
|
||||
// if the folder isn't connected, don't open the share dialog
|
||||
sendMessage(socket, message);
|
||||
} else {
|
||||
const QString file = QDir::cleanPath(localFile).mid(shareFolder->cleanPath().length()+1);
|
||||
SyncFileStatus fileStatus = this->fileStatus(shareFolder, file);
|
||||
|
||||
// Verify the file is on the server (to our knowledge of course)
|
||||
if (fileStatus.tag() != SyncFileStatus::STATUS_SYNC &&
|
||||
fileStatus.tag() != SyncFileStatus::STATUS_UPDATED) {
|
||||
const QString message = QLatin1String("SHARE:NOTSYNCED:")+QDir::toNativeSeparators(localFile);
|
||||
sendMessage(socket, message);
|
||||
return;
|
||||
}
|
||||
|
||||
const QString folderForPath = shareFolder->path();
|
||||
const QString remotePath = shareFolder->remotePath() + localFile.right(localFile.count()-folderForPath.count()+1);
|
||||
|
||||
// Can't share root folder
|
||||
if (QDir::cleanPath(remotePath) == "/") {
|
||||
const QString message = QLatin1String("SHARE:CANNOTSHAREROOT:")+QDir::toNativeSeparators(localFile);
|
||||
const QString message = QLatin1String("SHARE:CANNOTSHAREROOT:")+QDir::toNativeSeparators(localFile);
|
||||
sendMessage(socket, message);
|
||||
return;
|
||||
}
|
||||
@ -424,6 +435,17 @@ void SocketApi::command_SHARE_STATUS(const QString &localFile, QIODevice *socket
|
||||
const QString message = QLatin1String("SHARE_STATUS:NOP:")+QDir::toNativeSeparators(localFile);
|
||||
sendMessage(socket, message);
|
||||
} else {
|
||||
const QString file = QDir::cleanPath(localFile).mid(shareFolder->cleanPath().length()+1);
|
||||
SyncFileStatus fileStatus = this->fileStatus(shareFolder, file);
|
||||
|
||||
// Verify the file is on the server (to our knowledge of course)
|
||||
if (fileStatus.tag() != SyncFileStatus::STATUS_SYNC &&
|
||||
fileStatus.tag() != SyncFileStatus::STATUS_UPDATED) {
|
||||
const QString message = QLatin1String("SHARE_STATUS:NOTSYNCED:")+QDir::toNativeSeparators(localFile);
|
||||
sendMessage(socket, message);
|
||||
return;
|
||||
}
|
||||
|
||||
const Capabilities capabilities = shareFolder->accountState()->account()->capabilities();
|
||||
|
||||
if (!capabilities.shareAPI()) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user