Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
duniter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
typescript
duniter
Commits
8f81972b
Commit
8f81972b
authored
7 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
[enh] Enhance DB dumping to the disk
parent
9a13785f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/lib/dal/drivers/LokiFsAdapter.ts
+7
-5
7 additions, 5 deletions
app/lib/dal/drivers/LokiFsAdapter.ts
app/lib/dal/fileDALs/CFSCore.ts
+2
-6
2 additions, 6 deletions
app/lib/dal/fileDALs/CFSCore.ts
app/lib/system/directory.ts
+25
-5
25 additions, 5 deletions
app/lib/system/directory.ts
with
34 additions
and
16 deletions
app/lib/dal/drivers/LokiFsAdapter.ts
+
7
−
5
View file @
8f81972b
...
@@ -17,13 +17,13 @@ import {CFSCore} from "../fileDALs/CFSCore"
...
@@ -17,13 +17,13 @@ import {CFSCore} from "../fileDALs/CFSCore"
import
{
getNanosecondsTime
}
from
"
../../../ProcessCpuProfiler
"
import
{
getNanosecondsTime
}
from
"
../../../ProcessCpuProfiler
"
import
{
NewLogger
}
from
"
../../logger
"
import
{
NewLogger
}
from
"
../../logger
"
interface
Iterator
<
T
>
{
export
interface
Iterator
<
T
>
{
next
(
value
?:
any
):
IteratorResult
<
T
>
next
(
value
?:
any
):
IteratorResult
<
T
>
return
?(
value
?:
any
):
IteratorResult
<
T
>
return
?(
value
?:
any
):
IteratorResult
<
T
>
throw
?(
e
?:
any
):
IteratorResult
<
T
>
throw
?(
e
?:
any
):
IteratorResult
<
T
>
}
}
interface
IteratorResult
<
T
>
{
export
interface
IteratorResult
<
T
>
{
done
:
boolean
done
:
boolean
value
:
T
value
:
T
}
}
...
@@ -185,9 +185,7 @@ export class LokiFsAdapter {
...
@@ -185,9 +185,7 @@ export class LokiFsAdapter {
li
=
this
.
generateDestructured
({
partition
:
pinext
.
value
});
li
=
this
.
generateDestructured
({
partition
:
pinext
.
value
});
// iterate each of the lines generated by generateDestructured()
// iterate each of the lines generated by generateDestructured()
for
(
let
outline
of
li
)
{
await
this
.
cfs
.
fsStreamTo
(
filename
,
li
)
await
this
.
cfs
.
appendFile
(
filename
,
outline
+
"
\n
"
)
}
self
.
saveNextPartition
(
commit
,
pi
,
callback
)
self
.
saveNextPartition
(
commit
,
pi
,
callback
)
};
};
...
@@ -234,6 +232,10 @@ export class LokiFsAdapter {
...
@@ -234,6 +232,10 @@ export class LokiFsAdapter {
for
(
docidx
=
0
;
docidx
<
doccount
;
docidx
++
)
{
for
(
docidx
=
0
;
docidx
<
doccount
;
docidx
++
)
{
yield
JSON
.
stringify
(
coll
.
data
[
docidx
]);
yield
JSON
.
stringify
(
coll
.
data
[
docidx
]);
}
}
if
(
doccount
===
0
)
{
yield
''
}
}
}
};
};
...
...
This diff is collapsed.
Click to expand it.
app/lib/dal/fileDALs/CFSCore.ts
+
2
−
6
View file @
8f81972b
...
@@ -228,11 +228,7 @@ export class CFSCore {
...
@@ -228,11 +228,7 @@ export class CFSCore {
return
path
.
normalize
(
filePath
).
replace
(
/
\/
/g
,
'
__
'
).
replace
(
/
\\
/g
,
'
__
'
);
return
path
.
normalize
(
filePath
).
replace
(
/
\/
/g
,
'
__
'
).
replace
(
/
\\
/g
,
'
__
'
);
}
}
getPath
(
file
:
string
)
{
fsStreamTo
(
filename
:
string
,
iterator
:
IterableIterator
<
string
>
)
{
return
path
.
join
(
this
.
rootPath
,
file
)
return
this
.
qfs
.
fsStreamTo
(
path
.
join
(
this
.
rootPath
,
filename
),
iterator
)
}
appendFile
(
filename
:
string
,
content
:
string
)
{
return
this
.
qfs
.
fsAppend
(
path
.
join
(
this
.
rootPath
,
filename
),
content
)
}
}
}
}
This diff is collapsed.
Click to expand it.
app/lib/system/directory.ts
+
25
−
5
View file @
8f81972b
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
// GNU Affero General Public License for more details.
// GNU Affero General Public License for more details.
import
*
as
path
from
"
path
"
import
*
as
path
from
"
path
"
import
*
as
fs
from
"
fs
"
import
*
as
fs
from
'
fs
'
import
{
SQLiteDriver
}
from
"
../dal/drivers/SQLiteDriver
"
import
{
SQLiteDriver
}
from
"
../dal/drivers/SQLiteDriver
"
import
{
CFSCore
}
from
"
../dal/fileDALs/CFSCore
"
import
{
CFSCore
}
from
"
../dal/fileDALs/CFSCore
"
import
{
WoTBInstance
,
WoTBObject
}
from
"
../wot
"
import
{
WoTBInstance
,
WoTBObject
}
from
"
../wot
"
...
@@ -41,12 +41,12 @@ export interface FileSystem {
...
@@ -41,12 +41,12 @@ export interface FileSystem {
fsWrite
(
file
:
string
,
content
:
string
):
Promise
<
void
>
fsWrite
(
file
:
string
,
content
:
string
):
Promise
<
void
>
fsMakeDirectory
(
dir
:
string
):
Promise
<
void
>
fsMakeDirectory
(
dir
:
string
):
Promise
<
void
>
fsRemoveTree
(
dir
:
string
):
Promise
<
void
>
fsRemoveTree
(
dir
:
string
):
Promise
<
void
>
fs
Append
(
file
:
string
,
content
:
string
):
Promise
<
void
>
fs
StreamTo
(
file
:
string
,
iterator
:
IterableIterator
<
string
>
):
Promise
<
void
>
}
}
class
QioFileSystem
implements
FileSystem
{
class
QioFileSystem
implements
FileSystem
{
constructor
(
private
qio
:
any
)
{}
constructor
(
private
qio
:
any
,
private
isMemory
:
boolean
=
false
)
{}
async
fsExists
(
file
:
string
)
{
async
fsExists
(
file
:
string
)
{
return
this
.
qio
.
exists
(
file
)
return
this
.
qio
.
exists
(
file
)
...
@@ -68,8 +68,28 @@ class QioFileSystem implements FileSystem {
...
@@ -68,8 +68,28 @@ class QioFileSystem implements FileSystem {
return
this
.
qio
.
write
(
file
,
content
)
return
this
.
qio
.
write
(
file
,
content
)
}
}
fsAppend
(
file
:
string
,
content
:
string
):
Promise
<
void
>
{
async
fsStreamTo
(
file
:
string
,
iterator
:
IterableIterator
<
string
>
):
Promise
<
void
>
{
return
this
.
qio
.
append
(
file
,
content
)
if
(
this
.
isMemory
)
{
for
(
const
line
of
iterator
)
{
await
this
.
qio
.
append
(
file
,
line
)
}
}
else
{
// Use NodeJS streams for faster writing
let
wstream
=
fs
.
createWriteStream
(
file
)
await
new
Promise
(
async
(
res
,
rej
)
=>
{
// When done, return
wstream
.
on
(
'
close
'
,
(
err
:
any
)
=>
{
if
(
err
)
return
rej
(
err
)
res
()
})
// Write each line
for
(
const
line
of
iterator
)
{
wstream
.
write
(
line
+
"
\n
"
)
}
// End the writing
wstream
.
end
()
})
}
}
}
fsMakeDirectory
(
dir
:
string
):
Promise
<
void
>
{
fsMakeDirectory
(
dir
:
string
):
Promise
<
void
>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment