Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
24d82a23
Unverified
Commit
24d82a23
authored
Sep 28, 2023
by
Bruce MacDonald
Committed by
GitHub
Sep 28, 2023
Browse files
do not download updates multiple times (#633)
parent
5f4008c2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
40 deletions
+19
-40
app/src/index.ts
app/src/index.ts
+19
-21
app/src/telemetry.ts
app/src/telemetry.ts
+0
-19
No files found.
app/src/index.ts
View file @
24d82a23
...
@@ -5,7 +5,7 @@ import winston from 'winston'
...
@@ -5,7 +5,7 @@ import winston from 'winston'
import
'
winston-daily-rotate-file
'
import
'
winston-daily-rotate-file
'
import
*
as
path
from
'
path
'
import
*
as
path
from
'
path
'
import
{
analytics
,
id
}
from
'
./telemetry
'
import
{
v4
as
uuidv4
}
from
'
uuid
'
import
{
installed
}
from
'
./install
'
import
{
installed
}
from
'
./install
'
require
(
'
@electron/remote/main
'
).
initialize
()
require
(
'
@electron/remote/main
'
).
initialize
()
...
@@ -164,11 +164,11 @@ app.on('before-quit', () => {
...
@@ -164,11 +164,11 @@ app.on('before-quit', () => {
function
init
()
{
function
init
()
{
if
(
app
.
isPackaged
)
{
if
(
app
.
isPackaged
)
{
heartbeat
()
autoUpdater
.
checkForUpdates
()
autoUpdater
.
checkForUpdates
()
setInterval
(()
=>
{
setInterval
(()
=>
{
heartbeat
()
if
(
!
updateAvailable
)
{
autoUpdater
.
checkForUpdates
()
autoUpdater
.
checkForUpdates
()
}
},
60
*
60
*
1000
)
},
60
*
60
*
1000
)
}
}
...
@@ -234,28 +234,26 @@ app.on('window-all-closed', () => {
...
@@ -234,28 +234,26 @@ app.on('window-all-closed', () => {
}
}
})
})
// In this file you can include the rest of your app's specific main process
function
id
():
string
{
// code. You can also put them in separate files and import them here.
const
id
=
store
.
get
(
'
id
'
)
as
string
let
aid
=
''
try
{
aid
=
id
()
}
catch
(
e
)
{}
autoUpdater
.
setFeedURL
(
{
if
(
id
)
{
url
:
`https://ollama.ai/api/update?os=
${
process
.
platform
}
&arch=
${
process
.
arch
}
&version=
${
app
.
getVersion
()}
&id=
${
aid
}
`
,
return
id
}
)
}
async
function
heartbeat
()
{
const
uuid
=
uuidv4
()
analytics
.
track
({
store
.
set
(
'
id
'
,
uuid
)
anonymousId
:
aid
,
return
uuid
event
:
'
heartbeat
'
,
properties
:
{
version
:
app
.
getVersion
(),
},
})
}
}
autoUpdater
.
setFeedURL
({
url
:
`https://ollama.ai/api/update?os=
${
process
.
platform
}
&arch=
${
process
.
arch
}
&version=
${
app
.
getVersion
()}
&id=
${
id
()}
`
,
})
autoUpdater
.
on
(
'
error
'
,
e
=>
{
autoUpdater
.
on
(
'
error
'
,
e
=>
{
logger
.
error
(
`update check failed -
${
e
.
message
}
`
)
console
.
error
(
`update check failed -
${
e
.
message
}
`
)
console
.
error
(
`update check failed -
${
e
.
message
}
`
)
})
})
...
...
app/src/telemetry.ts
deleted
100644 → 0
View file @
5f4008c2
import
{
Analytics
}
from
'
@segment/analytics-node
'
import
{
v4
as
uuidv4
}
from
'
uuid
'
import
Store
from
'
electron-store
'
const
store
=
new
Store
()
export
const
analytics
=
new
Analytics
({
writeKey
:
process
.
env
.
TELEMETRY_WRITE_KEY
||
'
<empty>
'
})
export
function
id
():
string
{
const
id
=
store
.
get
(
'
id
'
)
as
string
if
(
id
)
{
return
id
}
const
uuid
=
uuidv4
()
store
.
set
(
'
id
'
,
uuid
)
return
uuid
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment