Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PB-1737]: Feat/rebranding #469

Open
wants to merge 47 commits into
base: feat/2-0-6-release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
5c63f5a
feat: change folder name
migueldesarrollosoftware Mar 14, 2024
2434b69
feat: change provider to pccloud
migueldesarrollosoftware Mar 14, 2024
773e882
feat: add brandpath to modify our icons when we want
migueldesarrollosoftware Mar 14, 2024
b5c1dbf
feat: modify brand to use pccloud
migueldesarrollosoftware Mar 14, 2024
97fc493
feat: add images
migueldesarrollosoftware Mar 15, 2024
a093165
modify name of app
migueldesarrollosoftware Mar 15, 2024
4af1519
Merge branch 'feat/2-0-6-release' of github.com:internxt/drive-deskto…
migueldesarrollosoftware Mar 19, 2024
d76e0b8
feat: add sync menu item
migueldesarrollosoftware Mar 21, 2024
a6b0787
feat: logic to run sync manually using update remote sync
migueldesarrollosoftware Mar 21, 2024
b2bde01
feat: fallback sync implemented on manual sync
migueldesarrollosoftware Mar 25, 2024
7bbac37
wip:
migueldesarrollosoftware Mar 27, 2024
ad41332
wip: change variable name
miguelsw Mar 29, 2024
1c8b3cb
feat: add last syncing timestamp
miguelsw Mar 29, 2024
82615b5
feat: permission to use sync
miguelsw Apr 1, 2024
fe879cf
fix: changing ||
miguelsw Apr 2, 2024
20eb78b
fix: typo solved
miguelsw Apr 2, 2024
24bd89d
Merge pull request #480 from internxt/feat/block-manual-sync-in-syncing
miguelsw Apr 3, 2024
4ae7153
Merge pull request #477 from internxt/feat/fallback-permission
miguelsw Apr 3, 2024
664a95b
modify comments
miguelsw Apr 3, 2024
b96e514
Merge branch 'feat/manual-sync' of https://github.com/internxt/drive-…
miguelsw Apr 3, 2024
f5fe501
fix: close any instance that does not have the lock
JoanVicens Apr 5, 2024
f280744
Merge branch 'feat/manual-sync' into feat/rebrand-pc-loud
miguelsw Apr 5, 2024
cad1cc3
feat: run fallback syncronizer after start
cg27shokworks Apr 5, 2024
7ef0320
Merge branch 'feat/sync-improve' of https://github.com/internxt/drive…
miguelsw Apr 5, 2024
b63410d
fix: luach syncronization at the process begining
cg27shokworks Apr 5, 2024
78769fb
Merge branch 'feat/rebrand-pc-loud' of https://github.com/internxt/dr…
miguelsw Apr 5, 2024
e39f851
feat: modify repository url
miguelsw Apr 5, 2024
97339bf
wip:
migueldesarrollosoftware Mar 27, 2024
0d3492f
wip: change variable name
miguelsw Mar 29, 2024
463472c
feat: add last syncing timestamp
miguelsw Mar 29, 2024
0222ec1
fix: changing ||
miguelsw Apr 2, 2024
2ec7e33
fix: typo solved
miguelsw Apr 2, 2024
9c998f2
Merge pull request #2 from internxt/feat/fallback-wait
miguelsw Apr 5, 2024
1f9f955
chore: remove some macos code
JoanVicens Apr 8, 2024
4fe1fc9
version update
JoanVicens Apr 8, 2024
1f05562
go back to .6
JoanVicens Apr 8, 2024
1da7698
chore: var rename
JoanVicens Apr 8, 2024
d838d0d
version update
JoanVicens Apr 8, 2024
6f322ce
wip: add sentry capture
miguelsw Apr 8, 2024
17d04df
Merge pull request #3 from internxt/feat/add-sentry-exceptions
miguelsw Apr 8, 2024
08ea280
feat: version changed to 2.0.8 to release
miguelsw Apr 9, 2024
bd56c6c
Merge pull request #4 from internxt/feat/change-version-2-0-8
miguelsw Apr 9, 2024
baecf35
Merge branch 'feat/release-2.0.8' into feat/rebrand-pc-loud
miguelsw Apr 9, 2024
e4ae3a9
Merge pull request #5 from internxt/feat/rebrand-pc-loud
miguelsw Apr 9, 2024
8807bd9
feat:
miguelsw Apr 9, 2024
3d9f9ef
Merge pull request #490 from internxt/feat/release-2.0.9
miguelsw Apr 11, 2024
a482517
merge branch
miguelsw Apr 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/brands/pc-cloud/icon.ico
Binary file not shown.
Binary file added assets/brands/pc-cloud/icons/256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/brands/pc-cloud/tray/alert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/brands/pc-cloud/tray/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/brands/pc-cloud/tray/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/brands/pc-cloud/tray/idle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/brands/pc-cloud/tray/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/brands/pc-cloud/tray/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/brands/pc-cloud/tray/loading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/brands/pc-cloud/tray/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/brands/pc-cloud/tray/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/brands/pc-cloud/tray/syncing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/brands/pc-cloud/tray/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/brands/pc-cloud/tray/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "internxt-drive",
"version": "2.0.6",
"version": "2.0.9",
"author": "Internxt <[email protected]>",
"description": "Internxt Drive client UI",
"license": "AGPL-3.0",
"repository": {
"url": "https://github.com/internxt/drive-desktop"
"url": "https://github.com/internxt/pc-cloud"
},
"scripts": {
"build": "concurrently \"npm run build:main\" \"npm run build:renderer\" \"npm run build:sync-engine\"",
Expand Down Expand Up @@ -46,7 +46,7 @@
]
},
"build": {
"productName": "Internxt Drive",
"productName": "PC Cloud",
"beforeBuild": "./beforeBuild.js",
"appId": "com.internxt.drive",
"asar": true,
Expand Down Expand Up @@ -107,7 +107,7 @@
},
"directories": {
"app": "release/app",
"buildResources": "assets",
"buildResources": "assets/brands/pc-cloud",
"output": "release/build"
},
"extraResources": [
Expand Down
2 changes: 1 addition & 1 deletion release/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "internxt-drive",
"version": "2.0.6",
"version": "2.0.9",
"description": "Internxt Drive client UI",
"main": "./dist/main/main.js",
"author": "Internxt <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion release/app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ uuid@^9.0.0:
resolved "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz"
integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==

virtual-drive@../../../../node-win:
virtual-drive@../../../node-win:
version "1.0.1"
dependencies:
dotenv "^16.4.1"
Expand Down
2 changes: 1 addition & 1 deletion src/apps/main/auto-launch/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from './linux-desktop-entry';

const appFolder = Path.dirname(process.execPath);
const appExe = Path.resolve(appFolder, 'Internxt Drive.exe');
const appExe = Path.resolve(appFolder, 'Pc Cloud.exe');
const exeName = Path.basename(process.execPath);

const path = process.platform === 'win32' ? appExe : undefined;
Expand Down
15 changes: 15 additions & 0 deletions src/apps/main/background-processes/sync-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import Logger from 'electron-log';
import eventBus from '../event-bus';
import nodeSchedule from 'node-schedule';
import * as Sentry from '@sentry/electron/main';

let worker: BrowserWindow | null = null;
let workerIsRunning = false;
Expand Down Expand Up @@ -45,7 +46,7 @@
Logger.warn('Health check failed, relaunching the worker');
workerIsRunning = false;
worker?.destroy();
spawnSyncEngineWorker();

Check warning on line 49 in src/apps/main/background-processes/sync-engine.ts

View workflow job for this annotation

GitHub Actions / 🧪 Lint and test

'spawnSyncEngineWorker' was used before it was defined
});

healthCheckSchedule = nodeSchedule.scheduleJob('*/30 * * * * *', async () => {
Expand Down Expand Up @@ -85,6 +86,7 @@
})
.catch((err) => {
Logger.error('[MAIN] Error loading sync engine worker', err);
Sentry.captureException(err);
});

worker.on('close', () => {
Expand Down Expand Up @@ -125,6 +127,7 @@
const stopPromise = new Promise<void>((resolve, reject) => {
ipcMain.once('SYNC_ENGINE_STOP_ERROR', (_, error: Error) => {
Logger.error('[MAIN] Error stopping sync engine worker', error);
Sentry.captureException(error);
reject(error);
});

Expand All @@ -151,6 +154,7 @@
} catch (err) {
// TODO: handle error
Logger.error(err);
Sentry.captureException(err);
} finally {
worker?.destroy();
workerIsRunning = false;
Expand All @@ -175,6 +179,7 @@
'ERROR_ON_STOP_AND_CLEAR_SYNC_ENGINE_PROCESS',
(_, error: Error) => {
Logger.error('[MAIN] Error stopping sync engine worker', error);
Sentry.captureException(error);
reject(error);
}
);
Expand Down Expand Up @@ -202,6 +207,7 @@
} catch (err) {
// TODO: handle error
Logger.error(err);
Sentry.captureException(err);
} finally {
worker?.destroy();
workerIsRunning = false;
Expand All @@ -215,6 +221,15 @@
} catch (err) {
// TODO: handle error
Logger.error(err);
Sentry.captureException(err);
}
}

export function fallbackSyncEngine() {
try {
worker?.webContents.send('FALLBACK_SYNC_ENGINE_PROCESS');
} catch (err) {
Logger.error(err);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/apps/main/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if (process.env.NODE_ENV !== 'development') {
// Handle open logs

ipcMain.on('open-logs', () => {
const logfilePath = log.transports.file.getFile().path;
const logFolderPath = path.dirname(logfilePath);
const logFilePath = log.transports.file.getFile().path;
const logFolderPath = path.dirname(logFilePath);
shell.openPath(logFolderPath);
});
10 changes: 6 additions & 4 deletions src/apps/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ import { setCleanUpFunction } from './quit';
import { stopSyncEngineWatcher } from './background-processes/sync-engine';
import { Theme } from '../shared/types/Theme';

const gotTheLock = app.requestSingleInstanceLock();

if (!gotTheLock) {
app.quit();
}

Logger.log(`Running ${packageJson.version}`);

Logger.log('Initializing Sentry for main process');
Expand All @@ -73,10 +79,6 @@ function checkForUpdates() {
autoUpdater.checkForUpdatesAndNotify();
}

if (process.platform === 'darwin') {
app.dock.hide();
}

if (process.env.NODE_ENV === 'production') {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const sourceMapSupport = require('source-map-support');
Expand Down
2 changes: 2 additions & 0 deletions src/apps/main/preload.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,7 @@ declare interface Window {
startRemoteSync: () => Promise<void>;
openUrl: (url: string) => Promise<void>;
getPreferredAppLanguage: () => Promise<Array<string>>;
syncManually: () => Promise<void>;
getRecentlywasSyncing: () => Promise<boolean>;
};
}
7 changes: 7 additions & 0 deletions src/apps/main/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,5 +296,12 @@ contextBridge.exposeInMainWorld('electron', {
getPreferredAppLanguage() {
return ipcRenderer.invoke('APP:PREFERRED_LANGUAGE');
},
syncManually() {
return ipcRenderer.invoke('SYNC_MANUALLY');
},
getRecentlywasSyncing() {
return ipcRenderer.invoke('CHECK_SYNC_IN_PROGRESS');
},

path,
});
2 changes: 2 additions & 0 deletions src/apps/main/realtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { io, Socket } from 'socket.io-client';
import { obtainToken } from './auth/service';
import eventBus from './event-bus';
import { broadcastToWindows } from './windows';
import { reportError } from '../renderer/utils/errors';

type XHRRequest = {
getResponseHeader: (headerName: string) => string[] | null;
Expand Down Expand Up @@ -57,6 +58,7 @@ function cleanAndStartRemoteNotifications() {

socket.on('connect_error', (error) => {
logger.error('❌ Remote notifications connect error: ', error);
reportError(error);
});

socket.on('event', (data) => {
Expand Down
27 changes: 27 additions & 0 deletions src/apps/main/remote-sync/RemoteSyncManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
RemoteSyncedFile,
SyncConfig,
SYNC_OFFSET_MS,
WAITING_AFTER_SYNCING
} from './helpers';
import { reportError } from '../bug-report/service';

Expand All @@ -24,6 +25,8 @@ export class RemoteSyncManager {
> = [];
private totalFilesSynced = 0;
private totalFoldersSynced = 0;
private lastSyncingFinishedTimestamp: Date | null = null;

constructor(
private db: {
files: DatabaseCollectionAdapter<DriveFile>;
Expand All @@ -47,10 +50,15 @@ export class RemoteSyncManager {
if (typeof callback !== 'function') return;
this.onStatusChangeCallbacks.push(callback);
}

getSyncStatus(): RemoteSyncStatus {
return this.status;
}

private getLastSyncingFinishedTimestamp() {
return this.lastSyncingFinishedTimestamp;
}

/**
* Check if the RemoteSyncManager is in SYNCED status
*
Expand All @@ -60,10 +68,22 @@ export class RemoteSyncManager {
return this.status === 'SYNCED';
}

/**
* Consult if recently the RemoteSyncManager was syncing
* @returns True if the RemoteSyncManager was syncing recently
* @returns False if the RemoteSyncManager was not syncing recently
*/
recentlyWasSyncing() {
const passedTime = Date.now() - ( this.getLastSyncingFinishedTimestamp()?.getTime() ?? Date.now() );
return passedTime < WAITING_AFTER_SYNCING;
}

resetRemoteSync() {
this.changeStatus('IDLE');
this.filesSyncStatus = 'IDLE';
this.foldersSyncStatus = 'IDLE';
this._placeholdersStatus = 'IDLE';
this.lastSyncingFinishedTimestamp = null;
this.totalFilesSynced = 0;
this.totalFoldersSynced = 0;
}
Expand Down Expand Up @@ -148,6 +168,7 @@ export class RemoteSyncManager {
return true;
}
private changeStatus(newStatus: RemoteSyncStatus) {
this.addLastSyncingFinishedTimestamp();
if (newStatus === this.status) return;
Logger.info(`RemoteSyncManager ${this.status} -> ${newStatus}`);
this.status = newStatus;
Expand All @@ -157,6 +178,12 @@ export class RemoteSyncManager {
});
}

private addLastSyncingFinishedTimestamp() {
if (this.status !== 'SYNCING') return;
Logger.info('Adding last syncing finished timestamp');
this.lastSyncingFinishedTimestamp = new Date();
}

private checkRemoteSyncStatus() {
if (this._placeholdersStatus === 'SYNCING') {
this.changeStatus('SYNCING');
Expand Down
42 changes: 30 additions & 12 deletions src/apps/main/remote-sync/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ import eventBus from '../event-bus';
import { RemoteSyncManager } from './RemoteSyncManager';
import { DriveFilesCollection } from '../database/collections/DriveFileCollection';
import { DriveFoldersCollection } from '../database/collections/DriveFolderCollection';
import { clearRemoteSyncStore } from './helpers';
import { clearRemoteSyncStore, RemoteSyncStatus } from './helpers';
import { getNewTokenClient } from '../../shared/HttpClient/main-process-client';
import Logger from 'electron-log';
import { ipcMain } from 'electron';
import { reportError } from '../bug-report/service';
import { sleep } from '../util';
import { broadcastToWindows } from '../windows';
import { updateSyncEngine } from '../background-processes/sync-engine';
import {
updateSyncEngine,
fallbackSyncEngine,
} from '../background-processes/sync-engine';

let initialSyncReady = false;
const driveFilesCollection = new DriveFilesCollection();
Expand Down Expand Up @@ -77,14 +80,27 @@ ipcMain.handle('get-remote-sync-status', () =>
remoteSyncManager.getSyncStatus()
);

eventBus.on('RECEIVED_REMOTE_CHANGES', async () => {
export async function updateRemoteSync(): Promise<void> {
// Wait before checking for updates, could be possible
// that we received the notification, but if we check
// for new data we don't receive it
await sleep(2_000);

await remoteSyncManager.startRemoteSync();
updateSyncEngine();
}
export async function fallbackRemoteSync(): Promise<void> {
await sleep(2_000);
fallbackSyncEngine();
}

ipcMain.handle('SYNC_MANUALLY', async () => {
Logger.info('[Manual Sync] Received manual sync event');
await updateRemoteSync();
await fallbackRemoteSync();
});

eventBus.on('RECEIVED_REMOTE_CHANGES', async () => {
await updateRemoteSync();
});

eventBus.on('USER_LOGGED_IN', async () => {
Expand All @@ -104,16 +120,18 @@ eventBus.on('USER_LOGGED_OUT', () => {

ipcMain.on('CHECK_SYNC', (event) => {
Logger.info('Checking sync');
event.sender.send(
'CHECK_SYNC_ENGINE_RESPONSE',
'Dato obtenido del proceso de sincronización'
);
event.sender.send('CHECK_SYNC_ENGINE_RESPONSE', '');
});

ipcMain.on('CHECK_SYNC_CHANGE_STATUS', async (_, placeholderStates) => {
await sleep(2_000);
Logger.info('[SYNC ENGINE] Changing status');
remoteSyncManager.placeholderStatus = 'SYNCING';
await sleep(7_00);
Logger.info('[SYNC ENGINE] Changing status', placeholderStates);
await sleep(5_000);
remoteSyncManager.placeholderStatus = placeholderStates;
});

ipcMain.handle('CHECK_SYNC_IN_PROGRESS', async () => {
const syncingStatus: RemoteSyncStatus = 'SYNCING';
const isSyncing = remoteSyncManager.getSyncStatus() === syncingStatus;
const recentlySyncing = remoteSyncManager.recentlyWasSyncing();
return isSyncing || recentlySyncing; // If it's syncing or recently was syncing
});
1 change: 1 addition & 0 deletions src/apps/main/remote-sync/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export type SyncConfig = {
};

export const SYNC_OFFSET_MS = 0;
export const WAITING_AFTER_SYNCING = 1000 * 60 * 3;

export const lastSyncedAtIsNewer = (
itemUpdatedAt: Date,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Logger from 'electron-log';
import { ThumbnailUploaderFactory } from '../infrastructure/ThumbnailUploaderFactory';
import { obtainImageToThumbnailIt } from './obtain-image-to-thumbnail-it';
import { reziseImage } from './resize-image';
import * as Sentry from '@sentry/electron/main';

export async function createAndUploadThumbnail(id: number, name: string) {
const uploader = ThumbnailUploaderFactory.build();
Expand All @@ -17,5 +18,6 @@ export async function createAndUploadThumbnail(id: number, name: string) {

await uploader.upload(id, thumbnail).catch((err) => {
Logger.error('[THUMBNAIL] Error uploading thumbnail: ', err);
Sentry.captureException(err);
});
}
3 changes: 2 additions & 1 deletion src/apps/main/token-scheduler/TokenScheduler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Logger from 'electron-log';
import jwtDecode, { JwtPayload } from 'jwt-decode';
import nodeSchedule from 'node-schedule';
import * as Sentry from '@sentry/electron/main';

const FIVE_SECONDS = 5 * 60;

Expand All @@ -20,7 +21,7 @@ export class TokenScheduler {
return decoded.exp || TokenScheduler.MAX_TIME;
} catch (err) {
Logger.error('[TOKEN] Token could be not decoded');

Sentry.captureException(err); // Use the 'Sentry' module to capture the exception
return TokenScheduler.MAX_TIME;
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/apps/main/tray/tray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ export const setTrayStatus = (status: TrayMenuState) => {
};

export function setupTrayIcon() {
const brandPath = '/brands/pc-cloud/';
const RESOURCES_PATH = app.isPackaged
? path.join(process.resourcesPath, 'assets')
: path.join(__dirname, '../../../../assets');
? path.join(process.resourcesPath, 'assets', brandPath)
: path.join(__dirname, '../../../../assets', brandPath);

const iconsPath = path.join(RESOURCES_PATH, 'tray');

Expand Down
Loading
Loading