Skip to content

Commit d66f11a

Browse files
committed
Revert "Update to libkiwix 14.1.0"
This reverts commit 3730b64. Revert libkiwix update
1 parent 2a4d0e7 commit d66f11a

File tree

11 files changed

+13
-134
lines changed

11 files changed

+13
-134
lines changed

Brewfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ brew "curl"
44

55
at_exit do
66
system "pre-commit install"
7-
system "curl -L -o - https://download.kiwix.org/release/libkiwix/libkiwix_xcframework-14.1.1.tar.gz | tar -x --strip-components 2"
7+
system "curl -L -o - https://download.kiwix.org/release/libkiwix/libkiwix_xcframework-14.0.0-1.tar.gz | tar -x --strip-components 2"
88
# Copy Clang module map to xcframework for Swift C++ Interoperability
99
system "cp Support/CoreKiwix.modulemap CoreKiwix.xcframework/ios-arm64/Headers/module.modulemap"
1010
system "cp Support/CoreKiwix.modulemap CoreKiwix.xcframework/ios-arm64_x86_64-simulator/Headers/module.modulemap"

Model/Hotspot/KiwixHotspot.mm

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,16 @@ - (Boolean) startFor: (nonnull NSSet *) zimFileIDs onPort: (int) port {
7070
}
7171

7272
- (NSString *_Nullable) address {
73-
std::vector<std::string> urls = self.server->getServerAccessUrls();
74-
if (urls.size() > 0) {
75-
return [NSString stringWithUTF8String: urls[0].c_str()];
73+
NSString *ipAddress = [NSString stringWithUTF8String: self.server->getAddress().addr.c_str()];
74+
return [NSString stringWithFormat:@"http://%@%@/", ipAddress, [self portNumberSuffix]];
75+
}
76+
77+
- (NSString *) portNumberSuffix {
78+
int portNumber = self.server->getPort();
79+
if(portNumber == 80) {
80+
return @"";
7681
} else {
77-
NSLog(@"no hotspot url was found");
78-
return nil;
82+
return [NSString stringWithFormat: @":%i", portNumber];
7983
}
8084
}
8185

Model/ZimFileService/SpellingsDBWrapper.h

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

Model/ZimFileService/SpellingsDBWrapper.mm

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

Model/ZimFileService/ZimFileService.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#import <Foundation/Foundation.h>
1717
#import "ZimFileMetaData.h"
1818
#import "zim/archive.h"
19-
#import "SpellingsDBWrapper.h"
2019

2120
@interface ZimFileService : NSObject
2221

@@ -35,10 +34,6 @@
3534
- (zim::Archive *_Nullable) archiveBy: (NSUUID *_Nonnull) zimFileID;
3635
- (zim::Archive *_Nullable) findArchiveBy: (NSUUID *_Nonnull) zimFileID;
3736
- (nonnull void *) getArchives;
38-
- (SpellingsDBWrapper *_Nullable)spellingsDBFor:(NSUUID *_Nonnull)zimFileID cachePath:(NSString *_Nonnull)contentPath;
39-
40-
# pragma mark - Spelling
41-
- (void) createSpellingIndex: (NSUUID *_Nonnull) zimFileID cachePath:(NSString *_Nonnull)contentPath NS_REFINED_FOR_SWIFT;
4237

4338
# pragma mark - Metadata
4439

Model/ZimFileService/ZimFileService.mm

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -105,36 +105,6 @@ - (nonnull void *) getArchives {
105105
return self.archives;
106106
}
107107

108-
# pragma mark - Spelling
109-
- (SpellingsDBWrapper *_Nullable)spellingsDBFor:(NSUUID *)zimFileID cachePath:(NSString *)contentPath {
110-
111-
zim::Archive *archive = [self archiveBy: zimFileID];
112-
if (archive == nil) {
113-
NSLog(@"cannot find ZIM by ID: %@ (%@)", zimFileID.UUIDString, contentPath);
114-
return nil;
115-
}
116-
try {
117-
@synchronized (self) {
118-
NSLog(@"createSpellingIndex for:%@, in: %@", zimFileID.UUIDString, contentPath);
119-
// this should be safe for utf-8, it comes from swift URL.path(percentEncoded=True)
120-
std::filesystem::path path = std::filesystem::path([contentPath cStringUsingEncoding: NSUTF8StringEncoding]);
121-
auto db = std::make_unique<kiwix::SpellingsDB>(*archive, path);
122-
SpellingsDBWrapper *wrapper = [[SpellingsDBWrapper alloc] initWithDB: std::move(db)];
123-
return wrapper;
124-
}
125-
} catch (std::exception e) {
126-
NSLog(@"create spelling index exception: %s", e.what());
127-
return nil;
128-
} catch (Xapian::DatabaseError e) {
129-
NSLog(@"create spelling index exception no database found: %s", e.get_description().c_str());
130-
return nil;
131-
}
132-
}
133-
134-
- (void) createSpellingIndex:(NSUUID *)zimFileID cachePath:(NSString *)contentPath {
135-
[self spellingsDBFor:zimFileID cachePath:contentPath];
136-
}
137-
138108
# pragma mark - Metadata
139109

140110
+ (ZimFileMetaData *_Nullable)getMetaDataWithFileURL:(NSURL *)url {
@@ -255,10 +225,10 @@ - (NSDictionary *)getContent:(NSUUID *)zimFileID contentPath:(NSString *)content
255225
- (NSDictionary *_Nullable) getDirectAccess: (NSUUID *)zimFileID contentPath:(NSString *)contentPath {
256226
try {
257227
zim::Item item = [self itemIn:zimFileID contentPath: contentPath];
258-
zim::ItemDataDirectAccessInfo info = item.getDirectAccessInformation();
228+
zim::Item::DirectAccessInfo info = item.getDirectAccessInformation();
259229
return @{
260-
@"path": [NSString stringWithUTF8String: info.filename.c_str()],
261-
@"offset": [NSNumber numberWithUnsignedLong: info.offset]
230+
@"path": [NSString stringWithUTF8String: info.first.c_str()],
231+
@"offset": [NSNumber numberWithUnsignedLong: info.second]
262232
};
263233
} catch(std::exception) {
264234
return nil;

Model/ZimFileService/ZimFileService.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@
5353
func openArchive(zimFileID: UUID) -> UUID? {
5454
__open(zimFileID)
5555
}
56-
57-
func createSpellingIndex(zimFileID: UUID, cacheDir: URL) {
58-
__createSpellingIndex(zimFileID, cachePath: cacheDir.path())
59-
}
6056

6157
/// Close a zim file
6258
/// - Parameter fileID: ID of the zim file to close

SwiftUI/Model/SearchOperation/SearchOperation.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ NS_ASSUME_NONNULL_BEGIN
2929

3030
- (id)initWithSearchText:(NSString *)searchText zimFileIDs:(NSSet *)zimFileIDs withSpellingCacheDir: (NSURL *_Nullable) spellCacheDir;
3131
- (void)performSearch;
32-
- (void) addSpellingCorrections NS_REFINED_FOR_SWIFT;
3332

3433
@end
3534

SwiftUI/Model/SearchOperation/SearchOperation.mm

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -195,33 +195,6 @@ -(void) addResult: (SearchResult *_Nonnull) searchResult {
195195
[self.results addObject: searchResult];
196196
}
197197

198-
# pragma mark - Spelling
199-
200-
- (void) addSpellingCorrections {
201-
[self.corrections removeAllObjects];
202-
NSString *contentPath = [self.spellCacheDir path];
203-
// apply for the list of ZimFileIds that are included in search
204-
for (NSUUID *zimFileID in self.zimFileIDs) {
205-
if (self.isCancelled) { return; }
206-
try {
207-
SpellingsDBWrapper *dbWrapper = [[ZimFileService sharedInstance] spellingsDBFor:zimFileID cachePath:contentPath];
208-
if(dbWrapper == nil) {
209-
return;
210-
}
211-
std::vector<std::string> spellCorrections = dbWrapper.cppDB->getSpellingCorrections(self.searchText_C, 1);
212-
NSArray *array = convertToArray(spellCorrections);
213-
if (self.isCancelled) { return; }
214-
[self.corrections addObjectsFromArray:array];
215-
NSInteger count = array.count;
216-
NSLog(@"addSpellingCorrections for %@: (%ld)", zimFileID, static_cast<long>(count));
217-
} catch (std::exception &e) {
218-
NSLog(@"spellingsCorrections exception: %s", e.what());
219-
} catch (Xapian::DatabaseError e) {
220-
NSLog(@"create spelling index exception no database found: %s", e.get_description().c_str());
221-
}
222-
}
223-
}
224-
225198
NSArray<NSString *> *convertToArray(const std::vector<std::string> &vec) {
226199
NSMutableArray<NSString *> *result = [NSMutableArray new];
227200
for (const std::string &s : vec) {

SwiftUI/Model/SearchOperation/SearchOperation.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ extension SearchOperation {
9898
return
9999
}
100100
Log.LibraryOperations.debug("perfoming search suggestsion")
101-
__addSpellingCorrections()
102101
let count: Int = __corrections.count
103102
Log.LibraryOperations.debug("found search suggestsion: \(count, privacy: .public)")
104103
}

0 commit comments

Comments
 (0)