Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 6 additions & 0 deletions Sources/PrivMXEndpointSwift/Errors/PrivMXEndpointError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ public enum PrivMXEndpointError : Error{
/// Falied to delete KVDB Entries.
case failedDeletingKvdbEntries(privmx.InternalError)

case failedSyncingFile(privmx.InternalError)

/// Gets the Message of the error.
///
Expand Down Expand Up @@ -384,6 +385,7 @@ public enum PrivMXEndpointError : Error{
.failedCheckingifStringIsBase64(let err),
.failedTrimmingString(let err),
.failedSplittingString(let err),
.failedSyncingFile(let err),
.failedGeneratingBIP39(let err):
return String(err.message)
}
Expand Down Expand Up @@ -505,6 +507,7 @@ public enum PrivMXEndpointError : Error{
.failedCheckingifStringIsBase64(let err),
.failedTrimmingString(let err),
.failedSplittingString(let err),
.failedSyncingFile(let err),
.failedGeneratingBIP39(let err):
return err.code.value
}
Expand Down Expand Up @@ -625,6 +628,7 @@ public enum PrivMXEndpointError : Error{
.failedCheckingifStringIsBase64(let err),
.failedTrimmingString(let err),
.failedSplittingString(let err),
.failedSyncingFile(let err),
.failedGeneratingBIP39(let err):
return String(err.name)
}
Expand Down Expand Up @@ -745,6 +749,7 @@ public enum PrivMXEndpointError : Error{
.failedCheckingifStringIsBase64(let err),
.failedTrimmingString(let err),
.failedSplittingString(let err),
.failedSyncingFile(let err),
.failedGeneratingBIP39(let err):
return String(err.description)
}
Expand Down Expand Up @@ -865,6 +870,7 @@ public enum PrivMXEndpointError : Error{
.failedCheckingifStringIsBase64(let err),
.failedTrimmingString(let err),
.failedSplittingString(let err),
.failedSyncingFile(let err),
.failedGeneratingBIP39(let err):
if let scope = err.scope.value{
return String(scope)
Expand Down
14 changes: 14 additions & 0 deletions Sources/PrivMXEndpointSwift/Stores/StoreApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,20 @@ public class StoreApi{
}
}

/// Synchronize file handle data with newset data on server.
///
/// - Parameter handle: Store File handle to sync
///
/// - Throws: if the operation fails.
public func syncFile(
handle: privmx.StoreFileHandle
) throws -> Void {
let res = api.syncFile(handle)
guard res.error.value == nil else {
throw PrivMXEndpointError.failedSyncingFile(res.error.value!)
}
}

/// Subscribe for the Store events on the given subscription query.
///
/// - Parameter subscriptionQueries: list of queries
Expand Down
29 changes: 29 additions & 0 deletions Sources/PrivMXEndpointSwiftNative/NativeStoreApiWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,35 @@ ResultWithError<std::nullptr_t> NativeStoreApiWrapper::deleteStore(const std::st
return res;
}

/**
* Synchronize file handle data with newset data on serwer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

server

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for pointing it out, I removed the whole comment(it was unnecessary here)
though it was copied straight from Cpp header...

* @param handle handle to read/write file data
*/
ResultWithError<std::nullptr_t> NativeStoreApiWrapper::syncFile(const StoreFileHandle){
ResultWithError<std::nullptr_t> res;
try {
getapi()->deleteStore(storeId);
}catch(core::Exception& err){
res.error = {
.name = err.getName(),
.code = err.getCode(),
.scope = err.getScope(),
.description = err.getDescription(),
.message = err.what()
};
}catch (std::exception & err) {
res.error ={
.name = "std::Exception",
.message = err.what()
};
}catch (...) {
res.error ={
.name = "Unknown Exception",
.message = "Failed to work"
};
}
return res;
}

ResultWithError<SubscriptionIdVector> NativeStoreApiWrapper::subscribeFor(const SubscriptionQueryVector& subscriptionQueries){
ResultWithError<SubscriptionIdVector> res;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ class NativeStoreApiWrapper{
*/
ResultWithError<std::nullptr_t> deleteFile(const std::string& fileId);

ResultWithError<std::nullptr_t> syncFile(const StoreFileHandle handle);

/**
* Subscribe for the Thread events on the given subscription query.
*
Expand Down