Skip to content

Commit b7ba6f7

Browse files
fix: multi space systems are now properly detected and handled (#12062)
* fix: multi space systems are now properly detected and handled * Revert "[test-only][full-ci] Fix GUI tests (#11963)" This reverts commit b056cf0. * fix: refactor dependency between SpaceManager and Space
1 parent d0a951d commit b7ba6f7

File tree

10 files changed

+35
-50
lines changed

10 files changed

+35
-50
lines changed

src/libsync/graphapi/space.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ const auto personalC = QLatin1String("personal");
3232
const auto sharesIdC = QLatin1String("a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668");
3333
}
3434

35-
Space::Space(SpacesManager *spacesManager, const OpenAPI::OAIDrive &drive)
35+
Space::Space(SpacesManager *spacesManager, const OpenAPI::OAIDrive &drive, const bool hasManyPersonalSpaces)
3636
: QObject(spacesManager)
3737
, _spaceManager(spacesManager)
3838
, _image(new SpaceImage(this))
39+
, _hasManyPersonalSpaces(hasManyPersonalSpaces)
3940
{
4041
setDrive(drive);
4142
connect(_image, &SpaceImage::imageChanged, this, &Space::imageChanged);
@@ -97,14 +98,15 @@ void SpaceImage::update()
9798

9899
QString Space::displayName() const
99100
{
100-
auto hasManyPersonalSpaces = _spaceManager->account()->capabilities().spacesSupport().enabled;
101-
if (hasManyPersonalSpaces) {
101+
if (_hasManyPersonalSpaces) {
102102
return _drive.getName();
103103
}
104104

105+
// other systems like oCIS have one personal and one shared space and their names are hard coded
105106
if (_drive.getDriveType() == personalC) {
106107
return tr("Personal");
107-
} else if (_drive.getId() == sharesIdC) {
108+
}
109+
if (_drive.getId() == sharesIdC) {
108110
// don't call it ShareJail
109111
return tr("Shares");
110112
}

src/libsync/graphapi/space.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ namespace GraphApi {
7777
OpenAPI::OAIDrive drive() const;
7878

7979
/***
80-
* Asign a priority to a drive, used for sorting
80+
* Assign a priority to a drive, used for sorting
8181
*/
8282
uint32_t priority() const;
8383

@@ -94,14 +94,16 @@ namespace GraphApi {
9494
void imageChanged();
9595

9696
private:
97-
Space(SpacesManager *spaceManager, const OpenAPI::OAIDrive &drive);
97+
Space(SpacesManager *spaceManager, const OpenAPI::OAIDrive &drive, bool hasManyPersonalSpaces);
9898
void setDrive(const OpenAPI::OAIDrive &drive);
9999

100100
SpacesManager *_spaceManager;
101101
OpenAPI::OAIDrive _drive;
102102

103103
SpaceImage *_image;
104104

105+
bool _hasManyPersonalSpaces;
106+
105107
friend class SpacesManager;
106108
friend class SpaceImage;
107109
};

src/libsync/graphapi/spacesmanager.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,22 @@ void SpacesManager::refresh()
5555
if (!_account->credentials()->ready()) {
5656
return;
5757
}
58-
// TODO: leak the job until we fixed the onwership https://github.com/owncloud/client/issues/11203
58+
59+
// TODO: leak the job until we fixed the ownership https://github.com/owncloud/client/issues/11203
5960
auto drivesJob = new Drives(_account->sharedFromThis(), nullptr);
6061
drivesJob->setTimeout(refreshTimeoutC);
6162
connect(drivesJob, &Drives::finishedSignal, this, [drivesJob, this] {
63+
// a system which provides multiple personal spaces the name of the drive is always used as display name
64+
auto hasManyPersonalSpaces = this->account()->capabilities().spacesSupport().hasMultiplePersonalSpaces;
65+
6266
drivesJob->deleteLater();
6367
if (drivesJob->httpStatusCode() == 200) {
6468
auto oldKeys = _spacesMap.keys();
6569
for (const auto &dr : drivesJob->drives()) {
6670
auto *space = this->space(dr.getId());
6771
oldKeys.removeAll(dr.getId());
6872
if (!space) {
69-
space = new Space(this, dr);
73+
space = new Space(this, dr, hasManyPersonalSpaces);
7074
_spacesMap.insert(dr.getId(), space);
7175
} else {
7276
space->setDrive(dr);

test/gui/shared/scripts/bdd_hooks.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,7 @@ def hook(context):
112112
os.makedirs(tmp_dir)
113113

114114
# sync connection folder display name
115-
# For oCIS, it will be the user's display name
116-
# and will be set while adding the account or creating resources
117-
if not get_config("ocis"):
118-
set_config("syncConnectionName", "ownCloud")
115+
set_config("syncConnectionName", "Personal" if get_config("ocis") else "ownCloud")
119116

120117

121118
# determines if the test scenario failed or not

test/gui/shared/scripts/helpers/ConfigHelper.py

-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ def get_default_home_dir():
100100
'ocis': False,
101101
'record_video_on_failure': False,
102102
'files_for_upload': os.path.join(CURRENT_DIR.parent.parent, 'files-for-upload'),
103-
'syncConnectionName': '',
104103
}
105104
CONFIG.update(DEFAULT_PATH_CONFIG)
106105

test/gui/shared/scripts/helpers/SetupClientHelper.py

+11-23
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,11 @@ def set_current_user_sync_path(sync_path):
7474

7575
def get_resource_path(resource='', user='', space=''):
7676
sync_path = get_config('currentUserSyncPath')
77-
if not sync_path.startswith(get_config('tempFolderPath')):
78-
if user:
79-
sync_path = user
80-
else:
81-
user = parse_username_from_sync_path(sync_path)
82-
if get_config('ocis'):
83-
space = (
84-
space
85-
or get_config('syncConnectionName')
86-
or get_displayname_for_user(user)
87-
)
88-
sync_path = join(sync_path, space)
77+
if user:
78+
sync_path = user
79+
if get_config('ocis'):
80+
space = space or get_config('syncConnectionName')
81+
sync_path = join(sync_path, space)
8982
sync_path = join(get_config('clientRootSyncPath'), sync_path)
9083
resource = resource.replace(sync_path, '').strip('/').strip('\\')
9184
if is_windows():
@@ -96,10 +89,6 @@ def get_resource_path(resource='', user='', space=''):
9689
)
9790

9891

99-
def parse_username_from_sync_path(sync_path):
100-
return sync_path.split('/').pop()
101-
102-
10392
def get_temp_resource_path(resource_name):
10493
return join(get_config('tempFolderPath'), resource_name)
10594

@@ -168,10 +157,12 @@ def generate_account_config(users, space='Personal'):
168157
server_url = get_config('localBackendUrl')
169158

170159
if is_ocis := get_config('ocis'):
171-
if space == 'Personal':
172-
space = get_displayname_for_user(username)
160+
set_config('syncConnectionName', space)
173161
sync_path = create_space_path(space)
174-
dav_endpoint = url_join('dav/spaces', get_space_id(space, username))
162+
space_name = space
163+
if space == 'Personal':
164+
space_name = get_displayname_for_user(username)
165+
dav_endpoint = url_join('dav/spaces', get_space_id(space_name, username))
175166

176167
args = {
177168
'url': url_join(server_url, dav_endpoint, ''),
@@ -199,10 +190,7 @@ def generate_account_config(users, space='Personal'):
199190
return sync_paths
200191

201192

202-
def setup_client(username, space=None):
203-
if not space or space == 'Personal':
204-
space = get_displayname_for_user(username)
205-
set_config('syncConnectionName', space)
193+
def setup_client(username, space='Personal'):
206194
sync_paths = generate_account_config([username], space)
207195
start_client()
208196
for _, sync_path in sync_paths.items():

test/gui/shared/steps/account_context.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@
1717
wait_for_initial_sync_to_complete,
1818
listen_sync_status_for_item,
1919
)
20-
from helpers.ConfigHelper import get_config, set_config, is_windows, is_linux
20+
from helpers.ConfigHelper import get_config, is_windows, is_linux
2121

2222

2323
@When('the user adds the following user credentials:')
2424
def step(context):
2525
account_details = get_client_details(context)
26-
set_config('syncConnectionName', get_displayname_for_user(account_details['user']))
2726
AccountConnectionWizard.add_user_credentials(
2827
account_details['user'], account_details['password']
2928
)
@@ -106,7 +105,6 @@ def step(context):
106105
@When('the user adds the following account:')
107106
def step(context):
108107
account_details = get_client_details(context)
109-
set_config('syncConnectionName', get_displayname_for_user(account_details['user']))
110108
AccountConnectionWizard.add_account(account_details)
111109
# wait for files to sync
112110
wait_for_initial_sync_to_complete(get_resource_path('/', account_details['user']))
@@ -115,10 +113,6 @@ def step(context):
115113
@Given('the user has entered the following account information:')
116114
def step(context):
117115
account_details = get_client_details(context)
118-
if account_details['user']:
119-
set_config(
120-
'syncConnectionName', get_displayname_for_user(account_details['user'])
121-
)
122116
AccountConnectionWizard.add_account_information(account_details)
123117

124118

test/gui/shared/steps/spaces_context.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
get_file_content,
1212
resource_exists,
1313
)
14-
from helpers.ConfigHelper import get_config, set_config
14+
from helpers.ConfigHelper import get_config
1515

1616

1717
@Given('the administrator has created a space "|any|"')
@@ -43,7 +43,6 @@ def step(context, user, space_name):
4343
enter_password = EnterPassword()
4444
if get_config('ocis'):
4545
enter_password.accept_certificate()
46-
set_config('syncConnectionName', space_name)
4746
enter_password.login_after_setup(user, password)
4847
# wait for files to sync
4948
wait_for_initial_sync_to_complete(get_resource_path('/', user, space_name))

test/gui/tst_addAccount/test.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Feature: adding accounts
7676
| user | Alice |
7777
| password | 1234 |
7878
When the user selects manual sync folder option in advanced section
79-
And the user syncs the "Alice Hansen" space
79+
And the user syncs the "Personal" space
8080
Then the folder "simple-folder" should exist on the file system
8181

8282
@skipOnOCIS

test/gui/tst_syncing/test.feature

+4-4
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Feature: Syncing files
6868
| user | Alice |
6969
| password | 1234 |
7070
When the user selects manual sync folder option in advanced section
71-
And the user selects "Alice Hansen" space in sync connection wizard
71+
And the user selects "Personal" space in sync connection wizard
7272
And the user sets the sync path in sync connection wizard
7373
And the user navigates back in the sync connection wizard
7474
And the user sets the temp folder "localSyncFolder" as local sync path in sync connection wizard
@@ -97,7 +97,7 @@ Feature: Syncing files
9797
| user | Alice |
9898
| password | 1234 |
9999
When the user selects manual sync folder option in advanced section
100-
And the user selects "Alice Hansen" space in sync connection wizard
100+
And the user selects "Personal" space in sync connection wizard
101101
And the user sets the sync path in sync connection wizard
102102
And the user selects "ownCloud" as a remote destination folder
103103
And the user disables VFS support for Windows
@@ -133,7 +133,7 @@ Feature: Syncing files
133133
| user | Alice |
134134
| password | 1234 |
135135
When the user selects manual sync folder option in advanced section
136-
And the user selects "Alice Hansen" space in sync connection wizard
136+
And the user selects "Personal" space in sync connection wizard
137137
And the user sets the sync path in sync connection wizard
138138
And the user selects "ownCloud" as a remote destination folder
139139
And the user disables VFS support for Windows
@@ -471,7 +471,7 @@ Feature: Syncing files
471471
| user | Alice |
472472
| password | 1234 |
473473
When the user selects manual sync folder option in advanced section
474-
And the user selects "Alice Hansen" space in sync connection wizard
474+
And the user selects "Personal" space in sync connection wizard
475475
And the user sets the temp folder "~`!@#$^&()-_=+{[}];',)PRN%" as local sync path in sync connection wizard
476476
And the user selects "ownCloud" as a remote destination folder
477477
And the user disables VFS support for Windows

0 commit comments

Comments
 (0)