@ -229,70 +229,70 @@ public extension LibSession {
// / c o n f i g w h i l e w e a r e r e a d i n g ( w h i c h c o u l d r e s u l t i n c r a s h e s )
return try existingDumpVariants
. reduce ( into : PendingChanges ( ) ) { result , variant in
guard
let conf = dependencies . caches [ . libSession ]
. config ( for : variant , publicKey : publicKey )
. wrappedValue
else { return }
// C h e c k i f t h e c o n f i g n e e d s t o b e p u s h e d
guard config_needs_push ( conf ) else {
// I f n o t t h e n t r y r e t r i e v e a n y o b s o l e t e h a s h e s t o b e r e m o v e d
guard let cObsoletePtr : UnsafeMutablePointer < config_string_list > = config_old_hashes ( conf ) else {
return
}
let obsoleteHashes : [ String ] = [ String ] (
pointer : cObsoletePtr . pointee . value ,
count : cObsoletePtr . pointee . len ,
defaultValue : [ ]
)
// I f t h e r e a r e n o o b s o l e t e h a s h e s t h e n n o n e e d t o r e t u r n a n y t h i n g
guard ! obsoleteHashes . isEmpty else { return }
result . append ( hashes : obsoleteHashes )
return
}
guard let cPushData : UnsafeMutablePointer < config_push_data > = config_push ( conf ) else {
let configCountInfo : String = {
switch variant {
case . userProfile : return " 1 profile " // s t r i n g l i n t : d i s a b l e
case . contacts : return " \( contacts_size ( conf ) ) contacts " // s t r i n g l i n t : d i s a b l e
case . userGroups : return " \( user_groups_size ( conf ) ) group conversations " // s t r i n g l i n t : d i s a b l e
case . convoInfoVolatile : return " \( convo_info_volatile_size ( conf ) ) volatile conversations " // s t r i n g l i n t : d i s a b l e
case . invalid : return " Invalid " // s t r i n g l i n t : d i s a b l e
try dependencies . caches [ . libSession ]
. config ( for : variant , publicKey : publicKey )
. mutate { conf in
guard conf != nil else { return }
// C h e c k i f t h e c o n f i g n e e d s t o b e p u s h e d
guard config_needs_push ( conf ) else {
// I f n o t t h e n t r y r e t r i e v e a n y o b s o l e t e h a s h e s t o b e r e m o v e d
guard let cObsoletePtr : UnsafeMutablePointer < config_string_list > = config_old_hashes ( conf ) else {
return
}
let obsoleteHashes : [ String ] = [ String ] (
pointer : cObsoletePtr . pointee . value ,
count : cObsoletePtr . pointee . len ,
defaultValue : [ ]
)
// I f t h e r e a r e n o o b s o l e t e h a s h e s t h e n n o n e e d t o r e t u r n a n y t h i n g
guard ! obsoleteHashes . isEmpty else { return }
result . append ( hashes : obsoleteHashes )
return
}
guard let cPushData : UnsafeMutablePointer < config_push_data > = config_push ( conf ) else {
let configCountInfo : String = {
switch variant {
case . userProfile : return " 1 profile " // s t r i n g l i n t : d i s a b l e
case . contacts : return " \( contacts_size ( conf ) ) contacts " // s t r i n g l i n t : d i s a b l e
case . userGroups : return " \( user_groups_size ( conf ) ) group conversations " // s t r i n g l i n t : d i s a b l e
case . convoInfoVolatile : return " \( convo_info_volatile_size ( conf ) ) volatile conversations " // s t r i n g l i n t : d i s a b l e
case . invalid : return " Invalid " // s t r i n g l i n t : d i s a b l e
}
} ( )
throw LibSessionError (
conf ,
fallbackError : . unableToGeneratePushData ,
logMessage : " [LibSession] Failed to generate push data for \( variant ) config data, size: \( configCountInfo ) , error "
)
}
} ( )
throw LibSessionError (
conf ,
fallbackError : . unableToGeneratePushData ,
logMessage : " [LibSession] Failed to generate push data for \( variant ) config data, size: \( configCountInfo ) , error "
)
}
let pushData : Data = Data (
bytes : cPushData . pointee . config ,
count : cPushData . pointee . config_len
)
let obsoleteHashes : [ String ] = [ String ] (
pointer : cPushData . pointee . obsolete ,
count : cPushData . pointee . obsolete_len ,
defaultValue : [ ]
)
let seqNo : Int64 = cPushData . pointee . seqno
cPushData . deallocate ( )
result . append (
data : PendingChanges . PushData (
data : pushData ,
seqNo : seqNo ,
variant : variant
) ,
hashes : obsoleteHashes
)
let pushData : Data = Data (
bytes : cPushData . pointee . config ,
count : cPushData . pointee . config_len
)
let obsoleteHashes : [ String ] = [ String ] (
pointer : cPushData . pointee . obsolete ,
count : cPushData . pointee . obsolete_len ,
defaultValue : [ ]
)
let seqNo : Int64 = cPushData . pointee . seqno
cPushData . deallocate ( )
result . append (
data : PendingChanges . PushData (
data : pushData ,
seqNo : seqNo ,
variant : variant
) ,
hashes : obsoleteHashes
)
}
}
}