Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dd-41-bug-fix-desktop'
Browse files Browse the repository at this point in the history
  • Loading branch information
JAlbertoGonzalez committed Dec 4, 2020
2 parents 003a7ca + 2d48e7f commit 681ff99
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 69 deletions.
2 changes: 1 addition & 1 deletion resources/osx/notarize.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ exports.default = async function notarizing (context) {
const { electronPlatformName, appOutDir } = context
if (electronPlatformName !== 'darwin') {
console.log('Notarize not needed. Skipped.')
return
} else {
console.log('Notarizing...')
return
}

const appName = context.packager.appInfo.productFilename
Expand Down
58 changes: 32 additions & 26 deletions src/main/traymenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,17 @@ class TrayMenu {
Logger.info('User switched to two way sync mode')
ConfigStore.set('syncMode', 'two-way')
app.emit('sync-stop')
analytics.track({
userId: ConfigStore.get('user.uuid'),
event: 'sync-mode-change',
platform: 'desktop',
properties: {
email: ConfigStore.get('user.email'),
sync_to: 'two-way'
}
})
if (ConfigStore.get('user.uuid')) {
analytics.track({
userId: ConfigStore.get('user.uuid'),
event: 'sync-mode-change',
platform: 'desktop',
properties: {
email: ConfigStore.get('user.email'),
sync_to: 'two-way'
}
})
}
}
},
{
Expand All @@ -127,29 +129,33 @@ class TrayMenu {
Logger.info('User switched to one way upload mode')
ConfigStore.set('syncMode', 'one-way-upload')
app.emit('sync-stop')
analytics.track({
userId: ConfigStore.get('user.uuid'),
event: 'sync-mode-change',
platform: 'desktop',
properties: {
email: ConfigStore.get('user.email'),
sync_to: 'one-way-upload'
}
})
if (ConfigStore.get('user.uuid')) {
analytics.track({
userId: ConfigStore.get('user.uuid'),
event: 'sync-mode-change',
platform: 'desktop',
properties: {
email: ConfigStore.get('user.email'),
sync_to: 'one-way-upload'
}
})
}
}
}]
},
{
label: 'Force sync',
click: function () {
analytics.track({
event: 'force-sync',
userId: ConfigStore.get('user.uuid'),
platform: 'desktop',
properties: {
storage_used: ConfigStore.get('usage')
}
})
if (ConfigStore.get('user.uuid')) {
analytics.track({
event: 'force-sync',
userId: ConfigStore.get('user.uuid'),
platform: 'desktop',
properties: {
storage_used: ConfigStore.get('usage')
}
})
}
app.emit('sync-start')
}
},
Expand Down
22 changes: 13 additions & 9 deletions src/renderer/components/XCloudPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,23 @@ export default {
.ClearAll()
.then(() => {
Logger.info('databases cleared due to log out')
const localUser = ConfigStore.get('user.uuid')
database
.ClearUser()
.then(() => {
analytics.track({
event: 'user-signout',
userId: ConfigStore.get('user.uuid'),
platform: 'desktop',
properties: {
email: ConfigStore.get('user.email')
}
})
if (localUser) {
analytics.track({
event: 'user-signout',
userId: localUser,
platform: 'desktop',
properties: {
email: ConfigStore.get('user.email')
}
})
}
database.compactAllDatabases()
ConfigStore.clear()
ConfigStore.delete('user')
ConfigStore.delete('usage')
remote.app.emit('update-menu')
this.$router.push('/').catch(() => {})
})
Expand Down
1 change: 0 additions & 1 deletion src/renderer/logic/downloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ function _downloadAllFiles() {
fs.copyFileSync(tempPath, item.fullpath)
fs.unlinkSync(tempPath)
Sync.setModifiedTime(item.fullpath, item.created_at).then(() => {
console.log(item)
analytics.track(
{
userId: ConfigStore.get('user.uuid'),
Expand Down
17 changes: 12 additions & 5 deletions src/renderer/logic/sync/OneWayUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,17 @@ async function SyncLogic(callback) {

app.once('sync-stop', () => {
isSyncing = false
app.emit('sync-off')
throw Error('1-WAY-UPLOAD stopped')
database.ClearAll().then(() => {
app.emit('sync-off')
throw Error('1-WAY-UPLOAD stopped')
}).catch((err) => {
if (err.message !== '1-WAY-UPLOAD stopped') {
ConfigStore.set('syncMode', 'one-way-upload')
throw Error('cannot stop 1-WAY-UPLOAD. ' + err.message)
} else {
throw Error(err)
}
})
})

isSyncing = true
Expand Down Expand Up @@ -166,9 +175,7 @@ async function SyncLogic(callback) {
start(callback)
})
} else {
database.ClearAll().then(() => start(callback)).catch(() => {
Logger.error('Cannot end up 1-way-upload, fatal error')
})
start(callback)
}
}
)
Expand Down
53 changes: 26 additions & 27 deletions src/renderer/logic/uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,19 @@ function uploadNewFile(storj, filePath, nCurrent, nTotal) {
// Clear tooltip text, the upload is finished.
app.emit('set-tooltip')
app.removeListener('sync-stop', stopDownloadHandler)

analytics.track(
{
userId: ConfigStore.get('user.uuid'),
event: 'file-upload-finished',
platform: 'desktop',
properties: {
email: ConfigStore.get('user.email'),
file_id: newFileId,
file_size: fileSize,
mode: ConfigStore.get('syncMode')
}
}
)
if (err) {
Logger.warn('Error uploading file', err.message)
Database.FileSet(filePath, null)
Expand All @@ -129,19 +141,6 @@ function uploadNewFile(storj, filePath, nCurrent, nTotal) {
if (networkId) {
newFileId = networkId
File.createFileEntry(bucketId, newFileId, encryptedFileName, fileExt, fileSize, folderId).then(res => {
analytics.track(
{
userId: ConfigStore.get('user.uuid'),
event: 'file-upload-finished',
platform: 'desktop',
properties: {
email: ConfigStore.get('user.email'),
file_id: newFileId,
file_size: fileSize,
mode: ConfigStore.get('syncMode')
}
}
)
resolve(res)
}).catch(resolve)
} else {
Expand Down Expand Up @@ -241,6 +240,19 @@ function uploadFile(storj, filePath, nCurrent, nTotal) {
if (fs.existsSync(tempFile)) {
fs.unlinkSync(tempFile)
}
analytics.track(
{
userId: ConfigStore.get('user.uuid'),
event: 'file-upload-finished',
platform: 'desktop',
properties: {
email: ConfigStore.get('user.email'),
file_id: newFileId,
file_size: fileSize,
mode: ConfigStore.get('syncMode')
}
}
)
app.emit('set-tooltip')
app.removeListener('sync-stop', stopDownloadHandler)
if (err) {
Expand All @@ -254,19 +266,6 @@ function uploadFile(storj, filePath, nCurrent, nTotal) {
} else {
File.createFileEntry(bucketId, newFileId, encryptedFileName, fileExt, fileSize, folderId, fileMtime)
.then(res => {
analytics.track(
{
userId: ConfigStore.get('user.uuid'),
event: 'file-upload-finished',
platform: 'desktop',
properties: {
email: ConfigStore.get('user.email'),
file_id: newFileId,
file_size: fileSize,
mode: ConfigStore.get('syncMode')
}
}
)
resolve(res)
})
.catch(err => { reject(err) })
Expand Down

0 comments on commit 681ff99

Please sign in to comment.