core-3nweb-client-lib 0.48.4 → 0.48.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -95,12 +95,9 @@ class ReadonlyPayloadV2 {
|
|
|
95
95
|
if (start === end) {
|
|
96
96
|
return undefined;
|
|
97
97
|
}
|
|
98
|
-
const startSecInd = this.contentSections
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
.findIndex(s => ((s.ofs + s.len) >= end));
|
|
102
|
-
(0, assert_1.assert)((startSecInd >= 0) && (endSecInd >= 0) &&
|
|
103
|
-
(startSecInd <= endSecInd));
|
|
98
|
+
const startSecInd = this.contentSections.findIndex(s => (s.ofs <= start));
|
|
99
|
+
const endSecInd = this.contentSections.findIndex(s => ((s.ofs + s.len) >= end));
|
|
100
|
+
(0, assert_1.assert)((startSecInd >= 0) && (endSecInd >= 0) && (startSecInd <= endSecInd));
|
|
104
101
|
return await this.syncProc.startOrChain((startSecInd === endSecInd) ?
|
|
105
102
|
async () => {
|
|
106
103
|
const s = this.contentSections[startSecInd];
|
|
@@ -790,8 +787,21 @@ function payloadLayoutException(msg, cause) {
|
|
|
790
787
|
}
|
|
791
788
|
async function sureReadOfBytesFrom(src, ofs, len) {
|
|
792
789
|
const bytes = await src.readAt(ofs, len);
|
|
793
|
-
(0, assert_1.assert)(!!bytes
|
|
794
|
-
|
|
790
|
+
(0, assert_1.assert)(!!bytes);
|
|
791
|
+
if (bytes.length === len) {
|
|
792
|
+
return bytes;
|
|
793
|
+
}
|
|
794
|
+
// somehow, on Android src.readAt(ofs, len) may produce a thing that is shorter than len, hence, loop below
|
|
795
|
+
len -= bytes.length;
|
|
796
|
+
ofs += bytes.length;
|
|
797
|
+
const chunks = [bytes];
|
|
798
|
+
while (len > 0) {
|
|
799
|
+
const chunk = await src.readAt(ofs, len);
|
|
800
|
+
(0, assert_1.assert)(!!chunk);
|
|
801
|
+
len -= chunk.length;
|
|
802
|
+
ofs += chunk.length;
|
|
803
|
+
}
|
|
804
|
+
return (0, buffer_utils_1.joinByteArrs)(chunks);
|
|
795
805
|
}
|
|
796
806
|
function noop() { }
|
|
797
807
|
// XXX we may add smaller bytes for packing section info: there is enough values
|