Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ struct FileProviderDomainDefaults {
/// > Warning: Do not change the raw values of these keys, as they are used in UserDefaults. Any change would make the already stored value inaccessible and be like a reset.
///
private enum ConfigKey: String {
case trashDeletionEnabled
case user
case userId
case serverUrl
Expand Down Expand Up @@ -84,29 +83,6 @@ struct FileProviderDomainDefaults {
}
}

///
/// Whether trash deletion is enabled or not.
///
var trashDeletionEnabled: Bool {
get {
let identifier = self.identifier.rawValue

if let value = internalConfig[ConfigKey.trashDeletionEnabled.rawValue] as? Bool {
logger.debug("Returning existing value \"\(value)\" for \"trashDeletionEnabled\" for file provider domain \"\(identifier)\".")
return value
} else {
return false
}
}

set {
let identifier = self.identifier.rawValue

logger.error("Setting value \"\(newValue)\" for \"trashDeletionEnabled\" for file provider domain \"\(identifier)\".")
internalConfig[ConfigKey.trashDeletionEnabled.rawValue] = newValue
}
}

///
/// The user name associated with the domain.
///
Expand Down Expand Up @@ -166,9 +142,4 @@ struct FileProviderDomainDefaults {
}
}
}

///
/// Whether a value for `trashDeletionEnabled` has been explicitly set.
///
lazy var trashDeletionSet = internalConfig[ConfigKey.trashDeletionEnabled.rawValue] != nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -452,13 +452,6 @@ import OSLog

logger.debug("Found item for identifier.", [.item: identifier, .name: item.filename])

guard config.trashDeletionEnabled || item.parentItemIdentifier != .trashContainer else {
logger.info("System requested deletion of item in trash, but deleting trash items is disabled. item: \(item.filename)")
removeSyncAction(actionId)
completionHandler(NSError.fileProviderErrorForRejectedDeletion(of: item))
return
}

let error = await item.delete(domain: domain, ignoredFiles: ignoredFiles, dbManager: dbManager)

if error != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
password:(NSString *)password
userAgent:(NSString *)userAgent;
- (void)removeAccountConfig;
- (void)getTrashDeletionEnabledStateWithCompletionHandler:(void(^)(BOOL enabled, BOOL set))completionHandler;
- (void)setTrashDeletionEnabled:(BOOL)enabled;
- (void)setIgnoreList:(NSArray<NSString *> *)ignoreList;

@end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,6 @@ class ClientCommunicationService: NSObject, NSFileProviderServiceSource, NSXPCLi
self.fpExtension.removeAccountConfig()
}

func getTrashDeletionEnabledState(completionHandler: @escaping (Bool, Bool) -> Void) {
let enabled = fpExtension.config.trashDeletionEnabled
let set = fpExtension.config.trashDeletionSet
completionHandler(enabled, set)
}

func setTrashDeletionEnabled(_ enabled: Bool) {
fpExtension.config.trashDeletionEnabled = enabled
logger.info("Trash deletion setting changed to: \(enabled)")
}

func setIgnoreList(_ ignoreList: [String]) {
self.fpExtension.ignoredFiles = IgnoredFilesMatcher(ignoreList: ignoreList)
logger.info("Ignore list updated.")
Expand Down
1 change: 1 addition & 0 deletions src/gui/macOS/fileprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#pragma once

#include <QObject>

Check failure on line 8 in src/gui/macOS/fileprovider.h

View workflow job for this annotation

GitHub Actions / build

src/gui/macOS/fileprovider.h:8:10 [clang-diagnostic-error]

'QObject' file not found

#include "fileproviderdomainmanager.h"
#include "fileprovidersocketserver.h"
Expand Down Expand Up @@ -36,6 +36,7 @@

private slots:
void configureXPC();
void onDomainReconfigurationFailed(const QString &accountId, const QString &errorMessage);

private:
std::unique_ptr<FileProviderDomainManager> _domainManager;
Expand Down
14 changes: 14 additions & 0 deletions src/gui/macOS/fileprovider_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "fileprovider.h"

#include <QLoggingCategory>
#include <QMessageBox>

#include "libsync/configfile.h"
#include "gui/macOS/fileproviderxpc.h"
Expand Down Expand Up @@ -36,6 +37,8 @@

if (_domainManager) {
connect(_domainManager.get(), &FileProviderDomainManager::domainSetupComplete, this, &FileProvider::configureXPC);
connect(_domainManager.get(), &FileProviderDomainManager::domainReconfigurationFailed,
this, &FileProvider::onDomainReconfigurationFailed);
_domainManager->start();
qCDebug(lcMacFileProvider()) << "Initialized file provider domain manager";
}
Expand Down Expand Up @@ -102,5 +105,16 @@
return _socketServer.get();
}

void FileProvider::onDomainReconfigurationFailed(const QString &accountId, const QString &errorMessage)
{
qCWarning(lcMacFileProvider) << "Domain reconfiguration failed for account:" << accountId << "Error:" << errorMessage;
QMessageBox::warning(nullptr,
tr("Virtual files configuration error"),
tr("Could not update the virtual files settings for account %1.\n\n"
"Error: %2\n\n"
"Please try again or restart the application.")
.arg(accountId, errorMessage));
}

} // namespace Mac
} // namespace OCC
2 changes: 2 additions & 0 deletions src/gui/macOS/fileproviderdomainmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#pragma once

#include <QObject>

Check failure on line 8 in src/gui/macOS/fileproviderdomainmanager.h

View workflow job for this annotation

GitHub Actions / build

src/gui/macOS/fileproviderdomainmanager.h:8:10 [clang-diagnostic-error]

'QObject' file not found

#include "accountstate.h"

Expand All @@ -31,6 +31,7 @@

signals:
void domainSetupComplete();
void domainReconfigurationFailed(const QString &accountId, const QString &errorMessage);

public slots:
void addFileProviderDomainForAccount(const OCC::AccountState * const accountState);
Expand All @@ -42,6 +43,7 @@
void removeFileProviderDomainForAccount(const OCC::AccountState * const accountState);
void disconnectFileProviderDomainForAccount(const OCC::AccountState * const accountState, const QString &reason);
void reconnectFileProviderDomainForAccount(const OCC::AccountState * const accountState);
void reconfigureFileProviderDomainForAccount(const QString &accountId);

void signalEnumeratorChanged(const OCC::Account * const account);
void slotAccountStateChanged(const OCC::AccountState * const accountState);
Expand Down
Loading
Loading