Skip to content

Commit 5f902a9

Browse files
authored
Merge branch 'main' into bidi-sanitize
2 parents 27af6aa + 855b00a commit 5f902a9

7 files changed

Lines changed: 48 additions & 77 deletions

File tree

.github/workflows/xcode.yml

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ on:
1414
- develop
1515

1616
env:
17-
DESTINATION_IOS: platform=iOS Simulator,name=iPhone 16,OS=18.1
17+
DESTINATION_IOS: platform=iOS Simulator,name=iPhone 16,OS=18.5
1818
DESTINATION_MACOS: platform=macOS,arch=x86_64
1919
SCHEME: NextcloudKit
20-
SERVER_BRANCH: stable28
21-
PHP_VERSION: 8.2
20+
SERVER_BRANCH: stable30
21+
PHP_VERSION: 8.3
2222

2323
jobs:
2424
build-and-test:
@@ -60,32 +60,12 @@ jobs:
6060
./server/occ config:system:set memcache.distributed --value="\\OC\\Memcache\\APCu"
6161
./server/occ background:cron
6262
PHP_CLI_SERVER_WORKERS=5 php -S localhost:8080 -t server/ &
63-
# - name: Setup Bundler and Install Gems
64-
# run: |
65-
# gem install bundler
66-
# bundle install
67-
# bundle update
68-
# - name: Install docker
69-
# run: |
70-
# # Workaround for https://github.com/actions/runner-images/issues/8104
71-
# brew remove --ignore-dependencies qemu
72-
# curl -o ./qemu.rb https://raw.githubusercontent.com/Homebrew/homebrew-core/dc0669eca9479e9eeb495397ba3a7480aaa45c2e/Formula/qemu.rb
73-
# brew install ./qemu.rb
74-
#
75-
# brew install docker
76-
# colima start
77-
# - name: Create docker test server and export enviroment variables
78-
# run: |
79-
# source ./create-docker-test-server.sh
80-
# if [ ! -f ".env-vars" ]; then
81-
# touch .env-vars
82-
# echo "export TEST_SERVER_URL=$TEST_SERVER_URL" >> .env-vars
83-
# echo "export TEST_USER=$TEST_USER" >> .env-vars
84-
# echo "export TEST_APP_PASSWORD=$TEST_APP_PASSWORD" >> .env-vars
85-
# fi
86-
# - name: Generate EnvVars file
87-
# run: |
88-
# ./generate-env-vars.sh
63+
64+
- name: Setup Xcode
65+
uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
66+
with:
67+
xcode-version: latest-stable
68+
8969
- name: Build & Test NextcloudKit
9070
run: |
9171
set -o pipefail && xcodebuild test -scheme "$SCHEME" \

.swiftlint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ empty_count:
1111

1212
line_length:
1313
warning: 400
14-
error: 400
14+
error: 450
1515

1616
function_body_length:
1717
warning: 200

Sourcery/EnvVars.stencil

Lines changed: 0 additions & 18 deletions
This file was deleted.

Sourcery/bin/sourcery

-18.9 MB
Binary file not shown.

Sources/NextcloudKit/NextcloudKit.swift

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,35 +108,45 @@ open class NextcloudKit {
108108
nkCommonInstance.nksessions.append(nkSession)
109109
}
110110

111+
/// Updates an existing `NKSession` stored in the synchronized array.
112+
///
113+
/// This method looks up the session by its `account` identifier, applies any non-nil
114+
/// parameters to mutate the session, and then replaces the stored value using
115+
/// `SynchronizedNKSessionArray.replace(account:with:)`.
116+
///
117+
/// - Parameters:
118+
/// - account: The account identifier used to locate the session to update.
119+
/// - urlBase: An optional new base URL for the session.
120+
/// - user: An optional new username for the session.
121+
/// - userId: An optional new user identifier for the session.
122+
/// - password: An optional new password or token for the session.
123+
/// - userAgent: An optional new User-Agent string for the session.
111124
public func updateSession(account: String,
112125
urlBase: String? = nil,
113126
user: String? = nil,
114127
userId: String? = nil,
115128
password: String? = nil,
116-
userAgent: String? = nil,
117-
replaceWithAccount: String? = nil) {
118-
guard var nkSession = nkCommonInstance.nksessions.session(forAccount: account) else {
129+
userAgent: String? = nil) {
130+
guard var newSession = nkCommonInstance.nksessions.session(forAccount: account) else {
119131
return
120132
}
121133

122134
if let urlBase {
123-
nkSession.urlBase = urlBase
135+
newSession.urlBase = urlBase
124136
}
125137
if let user {
126-
nkSession.user = user
138+
newSession.user = user
127139
}
128140
if let userId {
129-
nkSession.userId = userId
141+
newSession.userId = userId
130142
}
131143
if let password {
132-
nkSession.password = password
144+
newSession.password = password
133145
}
134146
if let userAgent {
135-
nkSession.userAgent = userAgent
136-
}
137-
if let replaceWithAccount {
138-
nkSession.account = replaceWithAccount
147+
newSession.userAgent = userAgent
139148
}
149+
nkCommonInstance.nksessions.replace(account: account, with: newSession)
140150
}
141151

142152
public func deleteCookieStorageForAccount(_ account: String) {

Sources/NextcloudKit/Utils/SynchronizedNKSessionArray.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,23 @@ public final class SynchronizedNKSessionArray: @unchecked Sendable {
7575
}
7676
}
7777

78+
/// Replaces the first stored session that matches the given account identifier with a new session.
79+
///
80+
/// This method performs the replacement in a thread-safe manner using a barrier write
81+
/// on the internal concurrent queue. If no session with the specified account is found,
82+
/// the array remains unchanged.
83+
///
84+
/// - Parameters:
85+
/// - account: The account identifier of the session to replace.
86+
/// - newSession: The `NKSession` instance that will replace the existing one.
87+
public func replace(account: String, with newSession: NKSession) {
88+
queue.async(flags: .barrier) {
89+
if let idx = self.array.firstIndex(where: { $0.account == account }) {
90+
self.array[idx] = newSession
91+
}
92+
}
93+
}
94+
7895
// MARK: - Write Operations
7996

8097
/// Appends a new session to the array.

generate-env-vars.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)