Skip to content

Commit c8c81b3

Browse files
authored
Merge branch 'nextcloud:master' into addtagsupportmac
2 parents a289c8e + e2410ff commit c8c81b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+350
-189
lines changed

doc/conffile.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ Some interesting values that can be set on the configuration file are:
4343
+----------------------------------+--------------------------+--------------------------------------------------------------------------------------------------------+
4444
| ``forceLoginV2`` | ``false`` | If the client should force the new login flow, eventhough some circumstances might need the old flow. |
4545
+----------------------------------+--------------------------+--------------------------------------------------------------------------------------------------------+
46-
| ``minChunkSize`` | ``1000000`` (1 MB) | Specifies the minimum chunk size of uploaded files in bytes. |
46+
| ``minChunkSize`` | ``5000000`` (5 MB) | Specifies the minimum chunk size of uploaded files in bytes. |
4747
+----------------------------------+--------------------------+--------------------------------------------------------------------------------------------------------+
48-
| ``maxChunkSize`` | ``1000000000`` (1000 MB) | Specifies the maximum chunk size of uploaded files in bytes. |
48+
| ``maxChunkSize`` | ``5000000000`` (5000 MB) | Specifies the maximum chunk size of uploaded files in bytes. |
4949
+----------------------------------+--------------------------+--------------------------------------------------------------------------------------------------------+
5050
| ``targetChunkUploadDuration`` | ``60000`` (1 minute) | Target duration in milliseconds for chunk uploads. |
5151
| | | The client adjusts the chunk size until each chunk upload takes approximately this long. |

src/common/utility.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ Q_DECLARE_LOGGING_CATEGORY(lcUtility)
5050
* @{
5151
*/
5252
namespace Utility {
53+
struct ProcessInfosForOpenFile {
54+
ulong processId;
55+
QString processName;
56+
};
57+
/**
58+
* @brief Queries the OS for processes that are keeping the file open(using it)
59+
*
60+
* @param filePath absolute file path
61+
* @return list of ProcessInfosForOpenFile
62+
*/
63+
OCSYNC_EXPORT QVector<ProcessInfosForOpenFile> queryProcessInfosKeepingFileOpen(const QString &filePath);
64+
5365
OCSYNC_EXPORT int rand();
5466
OCSYNC_EXPORT void sleep(int sec);
5567
OCSYNC_EXPORT void usleep(int usec);

src/common/utility_mac.mm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131

3232
namespace OCC {
3333

34+
QVector<Utility::ProcessInfosForOpenFile> Utility::queryProcessInfosKeepingFileOpen(const QString &filePath)
35+
{
36+
Q_UNUSED(filePath)
37+
return {};
38+
}
39+
3440
void Utility::setupFavLink(const QString &folder)
3541
{
3642
// Finder: Place under "Places"/"Favorites" on the left sidebar

src/common/utility_unix.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131

3232
namespace OCC {
3333

34+
QVector<Utility::ProcessInfosForOpenFile> Utility::queryProcessInfosKeepingFileOpen(const QString &filePath)
35+
{
36+
Q_UNUSED(filePath)
37+
return {};
38+
}
39+
3440
void Utility::setupFavLink(const QString &folder)
3541
{
3642
// Nautilus: add to ~/.gtk-bookmarks

src/common/utility_win.cpp

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
#include <comdef.h>
2424
#include <Lmcons.h>
25+
#include <psapi.h>
26+
#include <RestartManager.h>
2527
#include <shlguid.h>
2628
#include <shlobj.h>
2729
#include <string>
@@ -43,6 +45,72 @@ static const char runPathC[] = R"(HKEY_CURRENT_USER\Software\Microsoft\Windows\C
4345

4446
namespace OCC {
4547

48+
QVector<Utility::ProcessInfosForOpenFile> Utility::queryProcessInfosKeepingFileOpen(const QString &filePath)
49+
{
50+
QVector<ProcessInfosForOpenFile> results;
51+
52+
DWORD restartManagerSession = 0;
53+
WCHAR restartManagerSessionKey[CCH_RM_SESSION_KEY + 1] = {0};
54+
auto errorStatus = RmStartSession(&restartManagerSession, 0, restartManagerSessionKey);
55+
if (errorStatus != ERROR_SUCCESS) {
56+
return results;
57+
}
58+
59+
LPCWSTR files[] = {reinterpret_cast<LPCWSTR>(filePath.utf16())};
60+
errorStatus = RmRegisterResources(restartManagerSession, 1, files, 0, NULL, 0, NULL);
61+
if (errorStatus != ERROR_SUCCESS) {
62+
RmEndSession(restartManagerSession);
63+
return results;
64+
}
65+
66+
DWORD rebootReasons = 0;
67+
UINT rmProcessInfosNeededCount = 0;
68+
std::vector<RM_PROCESS_INFO> rmProcessInfos;
69+
auto rmProcessInfosRequestedCount = static_cast<UINT>(rmProcessInfos.size());
70+
errorStatus = RmGetList(restartManagerSession, &rmProcessInfosNeededCount, &rmProcessInfosRequestedCount, rmProcessInfos.data(), &rebootReasons);
71+
72+
if (errorStatus == ERROR_MORE_DATA) {
73+
rmProcessInfos.resize(rmProcessInfosNeededCount, {});
74+
rmProcessInfosRequestedCount = static_cast<UINT>(rmProcessInfos.size());
75+
errorStatus = RmGetList(restartManagerSession, &rmProcessInfosNeededCount, &rmProcessInfosRequestedCount, rmProcessInfos.data(), &rebootReasons);
76+
}
77+
78+
if (errorStatus != ERROR_SUCCESS || rmProcessInfos.empty()) {
79+
RmEndSession(restartManagerSession);
80+
return results;
81+
}
82+
83+
for (size_t i = 0; i < rmProcessInfos.size(); ++i) {
84+
const auto processHandle = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, rmProcessInfos[i].Process.dwProcessId);
85+
if (!processHandle) {
86+
continue;
87+
}
88+
89+
FILETIME ftCreate, ftExit, ftKernel, ftUser;
90+
91+
if (!GetProcessTimes(processHandle, &ftCreate, &ftExit, &ftKernel, &ftUser)
92+
|| CompareFileTime(&rmProcessInfos[i].Process.ProcessStartTime, &ftCreate) != 0) {
93+
CloseHandle(processHandle);
94+
continue;
95+
}
96+
97+
WCHAR processFullPath[MAX_PATH];
98+
DWORD processFullPathLength = MAX_PATH;
99+
if (QueryFullProcessImageNameW(processHandle, 0, processFullPath, &processFullPathLength) && processFullPathLength <= MAX_PATH) {
100+
const auto processFullPathString = QDir::fromNativeSeparators(QString::fromWCharArray(processFullPath));
101+
const QFileInfo fileInfoForProcess(processFullPathString);
102+
const auto processName = fileInfoForProcess.fileName();
103+
if (!processName.isEmpty()) {
104+
results.push_back(Utility::ProcessInfosForOpenFile{rmProcessInfos[i].Process.dwProcessId, processName});
105+
}
106+
}
107+
CloseHandle(processHandle);
108+
}
109+
RmEndSession(restartManagerSession);
110+
111+
return results;
112+
}
113+
46114
void Utility::setupFavLink(const QString &folder)
47115
{
48116
// First create a Desktop.ini so that the folder and favorite link show our application's icon.

src/csync/ConfigureChecks.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if (NOT LINUX)
3131
endif (NOT LINUX)
3232

3333
if(WIN32)
34-
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} psapi kernel32)
34+
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} psapi kernel32 Rstrtmgr)
3535
endif()
3636

3737
check_function_exists(utimes HAVE_UTIMES)

src/gui/filedetails/ShareDelegate.qml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,6 @@ GridLayout {
262262
ShareDetailsPage {
263263
id: shareDetailsPage
264264

265-
width: parent.width
266-
height: parent.height
267265
backgroundsVisible: root.backgroundsVisible
268266
accentColor: root.accentColor
269267

src/gui/filedetails/ShareDetailsPage.qml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ Page {
332332
mid: Style.darkerHover
333333
dark: Style.menuBorder
334334
button: Style.buttonBackgroundColor
335-
window: palette.dark // NOTE: Fusion theme uses darker window colour for the border of the checkbox
335+
window: Style.menuBorder
336336
base: Style.backgroundColor
337337
toolTipBase: Style.backgroundColor
338338
toolTipText: Style.ncTextColor
@@ -549,7 +549,7 @@ Page {
549549
mid: Style.darkerHover
550550
dark: Style.menuBorder
551551
button: Style.buttonBackgroundColor
552-
window: palette.dark // NOTE: Fusion theme uses darker window colour for the border of the checkbox
552+
window: Style.menuBorder
553553
base: Style.backgroundColor
554554
toolTipBase: Style.backgroundColor
555555
toolTipText: Style.ncTextColor
@@ -682,7 +682,7 @@ Page {
682682
mid: Style.darkerHover
683683
dark: Style.menuBorder
684684
button: Style.buttonBackgroundColor
685-
window: palette.dark // NOTE: Fusion theme uses darker window colour for the border of the checkbox
685+
window: Style.menuBorder
686686
base: Style.backgroundColor
687687
toolTipBase: Style.backgroundColor
688688
toolTipText: Style.ncTextColor
@@ -790,7 +790,7 @@ Page {
790790
mid: Style.darkerHover
791791
dark: Style.menuBorder
792792
button: Style.buttonBackgroundColor
793-
window: palette.dark // NOTE: Fusion theme uses darker window colour for the border of the checkbox
793+
window: Style.menuBorder
794794
base: Style.backgroundColor
795795
toolTipBase: Style.backgroundColor
796796
toolTipText: Style.ncTextColor

src/gui/filedetails/ShareeSearchField.qml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,7 @@ TextField {
185185
interactive: true
186186

187187
highlight: Rectangle {
188-
width: shareeListView.currentItem.width
189-
height: shareeListView.currentItem.height
188+
anchors.fill: shareeListView.currentItem
190189
color: palette.highlight
191190
}
192191
highlightFollowsCurrentItem: true
@@ -200,8 +199,7 @@ TextField {
200199

201200
model: root.shareeModel
202201
delegate: ShareeDelegate {
203-
anchors.left: parent.left
204-
anchors.right: parent.right
202+
width: shareeListView.contentItem.width
205203

206204
enabled: model.type !== Sharee.LookupServerSearchResults
207205
hoverEnabled: model.type !== Sharee.LookupServerSearchResults

src/gui/filedetails/sharemodel.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ QVariant ShareModel::data(const QModelIndex &index, const int role) const
189189
// Deal with roles that only return certain values for link or user/group share types
190190
case NoteEnabledRole:
191191
case ExpireDateEnabledRole:
192+
case HideDownloadEnabledRole:
192193
return false;
193194
case LinkRole:
194195
case LinkShareNameRole:

0 commit comments

Comments
 (0)