Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Actual Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Janne Mareike Koschinski
Actual Server
Commits
568f9f57
Verified
Commit
568f9f57
authored
3 years ago
by
Janne Mareike Koschinski
Browse files
Options
Downloads
Patches
Plain Diff
feat: allow choosing sync algorithm via config
parent
b8c138e8
No related branches found
No related tags found
No related merge requests found
Pipeline
#2769
passed
3 years ago
Stage: build
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app-sync.js
+17
-4
17 additions, 4 deletions
app-sync.js
load-config.js
+2
-1
2 additions, 1 deletion
load-config.js
with
19 additions
and
5 deletions
app-sync.js
+
17
−
4
View file @
568f9f57
...
...
@@ -9,15 +9,28 @@ let errorMiddleware = require('./util/error-middleware');
let
config
=
require
(
'
./load-config
'
);
let
{
getAccountDb
}
=
require
(
'
./account-db
'
);
let
simpleSync
=
require
(
'
./sync-simple
'
);
let
fullSync
=
require
(
'
./sync-full
'
);
let
actual
=
require
(
'
@actual-app/api
'
);
let
SyncPb
=
actual
.
internal
.
SyncProtoBuf
;
const
app
=
express
();
app
.
use
(
errorMiddleware
);
function
getSyncAlgorithm
()
{
switch
(
config
.
sync
)
{
case
'
simple
'
:
console
.
info
(
"
Using simple sync algorithm
"
)
return
require
(
'
./sync-simple
'
)
case
'
full
'
:
console
.
info
(
"
Using full sync algorithm
"
)
return
require
(
'
./sync-full
'
)
default
:
console
.
error
(
"
Unknown sync algorithm:
"
+
config
.
sync
)
process
.
abort
()
}
}
const
syncAlgorithm
=
getSyncAlgorithm
()
async
function
init
()
{
let
fileDir
=
join
(
process
.
env
.
ACTUAL_USER_FILES
||
config
.
userFiles
);
...
...
@@ -132,7 +145,7 @@ app.post('/sync', async (req, res) => {
// let simpleSync = require('./sync-simple');
// let {trie, newMessages } = simpleSync.sync(messages, since, file_id);
let
{
trie
,
newMessages
}
=
await
fullSync
.
sync
(
messages
,
since
,
file_id
);
let
{
trie
,
newMessages
}
=
await
getSyncAlgorithm
.
sync
(
messages
,
since
,
file_id
);
// encode it back...
let
responsePb
=
new
SyncPb
.
SyncResponse
();
...
...
This diff is collapsed.
Click to expand it.
load-config.js
+
2
−
1
View file @
568f9f57
...
...
@@ -11,7 +11,8 @@ try {
port
:
5006
,
hostname
:
'
0.0.0.0
'
,
serverFiles
:
join
(
root
,
'
server-files
'
),
userFiles
:
join
(
root
,
'
user-files
'
)
userFiles
:
join
(
root
,
'
user-files
'
),
sync
:
'
full
'
};
}
...
...
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