Skip to content

Commit

Permalink
merge branch monitor into fix/lopp-deleting-files
Browse files Browse the repository at this point in the history
  • Loading branch information
migueldesarrollosoftware committed Feb 9, 2024
2 parents e5d858a + a75c9b1 commit f0678a1
Show file tree
Hide file tree
Showing 45 changed files with 585 additions and 70 deletions.
10 changes: 10 additions & 0 deletions src/apps/main/background-processes/process-issues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ ipcMain.on('SYNC_INFO_UPDATE', (_, payload: ProcessInfoUpdatePayload) => {
}
});

ipcMain.on('SYNC_PROBLEM', (_, payload) => {
addProcessIssue({
action: 'GENERATE_TREE',
process: 'SYNC',
errorName: 'DUPLICATED_NODE',
kind: 'LOCAL',
name: payload.additionalData.name,
});
});

ipcMain.on('BACKUP_ISSUE', (_, issue: ProcessIssue) => {
addProcessIssue(issue);
});
Expand Down
8 changes: 8 additions & 0 deletions src/apps/main/fordwardToWindows.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { broadcastToWindows } from './windows';
import { ipcMainDrive } from './ipcs/mainDrive';
import { ipcMainSyncEngine } from './ipcs/ipcMainSyncEngine';
import { FileErrorInfo } from '../shared/IPC/events/drive';

ipcMainDrive.on('FILE_DELETED', (_, payload) => {
Expand Down Expand Up @@ -130,3 +131,10 @@ ipcMainDrive.on('FILE_DELETION_ERROR', (_, payload: FileErrorInfo) => {
name: nameWithExtension,
});
});

ipcMainSyncEngine.on('SYNC_PROBLEM', (_, payload) => {
broadcastToWindows('sync-info-update', {
action: 'SYNC_PROBLEM',
name: payload.additionalData.name,
});
});
12 changes: 7 additions & 5 deletions src/apps/renderer/localize/locales/en.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"login": {
"email": {
"section": "Email adress"
"section": "Email address"
},
"password": {
"section": "Password",
Expand All @@ -11,7 +11,7 @@
"show": "Show"
},
"action": {
"login": "Login",
"login": "Log in",
"is-logging-in": "Logging you in..."
},
"create-account": "Create account",
Expand Down Expand Up @@ -321,7 +321,8 @@
"no-permission": "Insufficient permissions",
"file-does-not-exist": "File doesn't exist",
"file-too-big": "Max upload size is 20GB. Please try smaller files.",
"file-non-extension": "Files without extensions are not supported."
"file-non-extension": "Files without extensions are not supported.",
"duplicated-node": "It appears that there are duplicate file or folder names in this directory. Please rename one of them to ensure synchronization"
},
"error-messages": {
"no-internet": "Looks like you are not connected to the internet, we'll try again later",
Expand All @@ -334,9 +335,10 @@
"unknown": "An unknown error ocurred while trying to sync your files",
"empty-file": "We don't support files with a size of 0 bytes because of our processes of sharding and encryption",
"bad-response": "We got a bad response from our servers while processing this file. Please, try starting the sync process again.",
"file-does-not-exist": "This file was present when we compared your local folder with your Internxt drive but dissapeared when we tried to access it. If you deleted this file, don't worry, this error should dissapear the next time the sync process starts.",
"file-does-not-exist": "This file was present when we compared your local folder with your Internxt drive but disappeared when we tried to access it. If you deleted this file, don't worry, this error should dissapear the next time the sync process starts.",
"file-too-big": "Max upload size is 20GB. Please try smaller files.",
"file-non-extension": "Files without extensions are not supported. Not synchronized."
"file-non-extension": "Files without extensions are not supported. Not synchronized.",
"duplicated-node": "There are two elements (file or folder) with the same name on a folder. Rename one of them to sync them both"
},
"report-modal": {
"actions": {
Expand Down
6 changes: 4 additions & 2 deletions src/apps/renderer/localize/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@
"no-permission": "Permisos insuficientes",
"file-does-not-exist": "El archivo no existe",
"file-too-big": "El tamaño máximo de carga es de 20GB. Por favor, intenta con archivos más pequeños.",
"file-non-extension": "Archivos sin extensión no son soportados"
"file-non-extension": "Archivos sin extensión no son soportados",
"duplicated-node": "Hay un conflicto con el elemento"
},
"error-messages": {
"no-internet": "No estás conectado a Internet, lo intentaremos más tarde",
Expand All @@ -335,7 +336,8 @@
"bad-response": "Error de servidor al procesar este archivo. Por favor, intente iniciar de nuevo el proceso de sincronización",
"file-does-not-exist": "Este archivo estaba presente cuando comparamos su carpeta local con su unidad Internxt, pero desapareció cuando intentamos acceder a él. Si has eliminado este archivo, no te preocupes, este error debería desaparecer la próxima vez que se inicie el proceso de sincronización",
"file-too-big": "El tamaño máximo de carga es de 20GB. Por favor, intenta con archivos más pequeños.",
"file-non-extension": "Los archivos sin extensiones no son soportados. No sincronizado"
"file-non-extension": "Los archivos sin extensiones no son soportados. No sincronizado",
"duplicated-node": "Hay dos elementos (archivo o carpeta) con el mismo nombre en una carpeta. Cambia el nombre de uno de ellos para sincronizar ambos."
},
"report-modal": {
"actions": {
Expand Down
6 changes: 4 additions & 2 deletions src/apps/renderer/localize/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@
"no-internet-connection": "Pas de connexion internet",
"no-permission": "Permissions insuffisantes",
"file-does-not-exist": "Le fichier n'existe pas",
"file-too-big": "La taille maximale de téléchargement est de 20 GB. Veuillez essayer des fichiers plus petits."
"file-too-big": "La taille maximale de téléchargement est de 20 GB. Veuillez essayer des fichiers plus petits.",
"duplicated-node": "Il y a un conflit avec l'élément."
},
"error-messages": {
"no-internet": "Il semble que vous ne soyez pas connecté à l'internet, nous réessayerons plus tard",
Expand All @@ -329,7 +330,8 @@
"bad-response": "Nous avons reçu une mauvaise réponse de nos serveurs lors du traitement de ce fichier. Veuillez essayer de relancer le processus de synchronisation.",
"file-does-not-exist": "Ce fichier était présent lorsque nous avons comparé votre dossier local avec votre disque interne, mais il a disparu lorsque nous avons essayé d'y accéder. Si vous avez supprimé ce fichier, ne vous inquiétez pas, cette erreur devrait disparaître au prochain démarrage du processus de synchronisation.",
"file-too-big": "La taille maximale de téléchargement est de 20 GB. Veuillez essayer des fichiers plus petits.",
"file-non-extension": "Les archives sans extensions ne sont pas supportées. Non synchronisées"
"file-non-extension": "Les archives sans extensions ne sont pas supportées. Non synchronisées",
"duplicated-node": "Il y a deux éléments (fichier ou dossier) avec le même nom dans un dossier. Renommez l'un d'eux pour les synchroniser tous les deux."
},
"report-modal": {
"actions": {
Expand Down
2 changes: 2 additions & 0 deletions src/apps/renderer/messages/process-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const shortMessages: ProcessErrorMessages = {
UNKNOWN: 'issues.short-error-messages.unknown',
FILE_TOO_BIG: 'issues.short-error-messages.file-too-big',
FILE_NON_EXTENSION: 'issues.short-error-messages.file-non-extension',
DUPLICATED_NODE: 'issues.short-error-messages.duplicated-node',
};

export const longMessages: ProcessErrorMessages = {
Expand All @@ -25,4 +26,5 @@ export const longMessages: ProcessErrorMessages = {
UNKNOWN: 'issues.error-messages.unknown',
FILE_TOO_BIG: 'issues.error-messages.file-too-big',
FILE_NON_EXTENSION: 'issues.error-messages.file-non-extension',
DUPLICATED_NODE: 'issues.error-messages.duplicated-node',
};
2 changes: 1 addition & 1 deletion src/apps/renderer/pages/ProcessIssues/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function Item({

<div className="flex flex-col space-y-1">
<h1
className="flex flex-1 flex-col truncate text-base font-medium leading-5 text-gray-100"
className="flex flex-1 flex-col text-base font-medium leading-5 text-gray-100"
data-test="sync-issue-name"
>
{translate(shortMessages[errorName])}
Expand Down
9 changes: 6 additions & 3 deletions src/apps/renderer/pages/Widget/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ export function Item({
action === 'DOWNLOAD_ERROR' ||
action === 'UPLOAD_ERROR' ||
action === 'RENAME_ERROR' ||
action === 'METADATA_READ_ERROR')
action === 'METADATA_READ_ERROR' ||
action === 'GENERATE_TREE')
? 'text-red'
: undefined
}`}
Expand All @@ -78,7 +79,8 @@ export function Item({
action === 'DOWNLOAD_ERROR' ||
action === 'UPLOAD_ERROR' ||
action === 'RENAME_ERROR' ||
action === 'METADATA_READ_ERROR')
action === 'METADATA_READ_ERROR' ||
action === 'GENERATE_TREE')
? description
: undefined
}
Expand Down Expand Up @@ -123,7 +125,8 @@ export function Item({
action === 'DOWNLOAD_ERROR' ||
action === 'UPLOAD_ERROR' ||
action === 'RENAME_ERROR' ||
action === 'METADATA_READ_ERROR') && (
action === 'METADATA_READ_ERROR' ||
action === 'GENERATE_TREE') && (
<WarningCircle size={24} className="text-red" weight="regular" />
)}
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/apps/shared/IPC/events/sync-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ export type SyncEngineInvocableFunctions = {
// TODO: change how errors are reported to the ui
export type ProcessInfoUpdate = {
SYNC_INFO_UPDATE: (payload: ProcessInfoUpdatePayload) => void;
SYNC_PROBLEM: (payload: {
key: string;
additionalData: Record<string, any>;
}) => void;
};

export type FromProcess = FilesEvents &
Expand Down
8 changes: 6 additions & 2 deletions src/apps/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ export type ProcessErrorName =
| 'FILE_NON_EXTENSION'

// Unknown error
| 'UNKNOWN';
| 'UNKNOWN'

// Duplicated node path
| 'DUPLICATED_NODE';

export class ProcessError extends Error {
details: ErrorDetails;
Expand Down Expand Up @@ -213,7 +216,8 @@ export type ProcessIssue = ProcessInfoBase & {
| 'DOWNLOAD_ERROR'
| 'RENAME_ERROR'
| 'DELETE_ERROR'
| 'METADATA_READ_ERROR';
| 'METADATA_READ_ERROR'
| 'GENERATE_TREE';

errorName: ProcessErrorName;
process: 'SYNC' | 'BACKUPS';
Expand Down
14 changes: 14 additions & 0 deletions src/apps/sync-engine/BindingManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class BindingsManager {

async start(version: string, providerId: string) {
await this.stop();
await this.pollingStart();

const controllers = buildControllers(this.container);

Expand Down Expand Up @@ -215,6 +216,7 @@ export class BindingsManager {

async stop() {
await this.container.virtualDrive.disconnectSyncRoot();
this.container.pollingMonitorStop.run();
}

async cleanUp() {
Expand Down Expand Up @@ -276,4 +278,16 @@ export class BindingsManager {
Logger.error('[SYNC ENGINE] ', error);
}
}

private async pollingStart() {
return this.container.pollingMonitorStart.run(this.polling.bind(this));
}

private async polling(): Promise<void> {
Logger.info('[SYNC ENGINE] Monitoring polling...');
const fileInPendingPaths =
(await this.container.virtualDrive.getPlaceholderWithStatePending()) as Array<string>;
Logger.info('[SYNC ENGINE] fileInPendingPaths', fileInPendingPaths);
await this.container.fileSyncOrchestrator.run(fileInPendingPaths);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export class AddController extends CallbackController {
const posixDir =
PlatformPathConverter.getFatherPathPosix(posixRelativePath);
try {
await new Promise((resolve) => setTimeout(resolve, 1000));
await this.runFolderCreator(posixDir);
} catch (error) {
Logger.error('Error creating folder father creation:', error);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { FileCreationOrchestrator } from '../../../../context/virtual-drive/boundaryBridge/application/FileCreationOrchestrator';
import { FileSyncOrchestrator } from '../../../../context/virtual-drive/boundaryBridge/application/FileSyncOrchestrator';

export interface BoundaryBridgeContainer {
fileCreationOrchestrator: FileCreationOrchestrator;
fileSyncOrchestrator: FileSyncOrchestrator;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { BoundaryBridgeContainer } from './BoundaryBridgeContainer';
import { ContentsContainer } from '../contents/ContentsContainer';
import { FilesContainer } from '../files/FilesContainer';
import { FileCreationOrchestrator } from '../../../../context/virtual-drive/boundaryBridge/application/FileCreationOrchestrator';
import { FileSyncOrchestrator } from '../../../../context/virtual-drive/boundaryBridge/application/FileSyncOrchestrator';

export function buildBoundaryBridgeContainer(
contentsContainer: ContentsContainer,
Expand All @@ -13,7 +14,13 @@ export function buildBoundaryBridgeContainer(
filesContainer.sameFileWasMoved
);

const fileSyncOrchestrator = new FileSyncOrchestrator(
contentsContainer.contentsUploader,
filesContainer.fileSyncronizer
);

return {
fileCreationOrchestrator,
fileSyncOrchestrator,
};
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import crypt from '../../../../context/shared/infrastructure/crypt';
import { Traverser } from '../../../../context/virtual-drive/items/application/Traverser';
import { DependencyInjectionUserProvider } from './user';
import { ipcRendererSyncEngine } from '../../ipcRendererSyncEngine';

export class DependencyInjectionTraverserProvider {
private static traverser: Traverser;
Expand All @@ -12,7 +13,11 @@ export class DependencyInjectionTraverserProvider {

const user = DependencyInjectionUserProvider.get();

const traverser = Traverser.existingItems(crypt, user.root_folder_id);
const traverser = Traverser.existingItems(
crypt,
ipcRendererSyncEngine,
user.root_folder_id
);

DependencyInjectionTraverserProvider.traverser = traverser;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,24 @@ import { RepositoryPopulator } from '../../../../context/virtual-drive/files/app
import { RetrieveAllFiles } from '../../../../context/virtual-drive/files/application/RetrieveAllFiles';
import { SameFileWasMoved } from '../../../../context/virtual-drive/files/application/SameFileWasMoved';
import { FileFolderContainerDetector } from '../../../../context/virtual-drive/files/application/FileFolderContainerDetector';
import { FileSyncronizer } from '../../../../context/virtual-drive/files/application/FileSyncronizer';
import { FilePlaceholderConverter } from '../../../../context/virtual-drive/files/application/FIlePlaceholderConverter';
import { FileSyncStatusUpdater } from '../../../../context/virtual-drive/files/application/FileSyncStatusUpdater';

export interface FilesContainer {
fileFinderByContentsId: FileFinderByContentsId;
fileDeleter: FileDeleter;
fileFolderContainerDetector: FileFolderContainerDetector;
filePathUpdater: FilePathUpdater;
fileCreator: FileCreator;
fileSyncronizer: FileSyncronizer;
filePlaceholderCreatorFromContentsId: FilePlaceholderCreatorFromContentsId;
createFilePlaceholderOnDeletionFailed: CreateFilePlaceholderOnDeletionFailed;
sameFileWasMoved: SameFileWasMoved;
retrieveAllFiles: RetrieveAllFiles;
repositoryPopulator: RepositoryPopulator;
filesPlaceholderCreator: FilesPlaceholderCreator;
filesPlaceholderUpdater: FilesPlaceholderUpdater;
filePlaceholderConverter: FilePlaceholderConverter;
fileSyncStatusUpdater: FileSyncStatusUpdater;
}
23 changes: 23 additions & 0 deletions src/apps/sync-engine/dependency-injection/files/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import { NodeWinLocalFileSystem } from '../../../../context/virtual-drive/files/
import { LocalFileIdProvider } from '../../../../context/virtual-drive/shared/application/LocalFileIdProvider';
import { DependencyInjectionHttpClientsProvider } from '../common/clients';
import { FileFolderContainerDetector } from '../../../../context/virtual-drive/files/application/FileFolderContainerDetector';
import { FileSyncronizer } from '../../../../context/virtual-drive/files/application/FileSyncronizer';
import { FilePlaceholderConverter } from '../../../../context/virtual-drive/files/application/FIlePlaceholderConverter';
import { FileSyncStatusUpdater } from '../../../../context/virtual-drive/files/application/FileSyncStatusUpdater';

export async function buildFilesContainer(
folderContainer: FoldersContainer,
Expand Down Expand Up @@ -121,12 +124,30 @@ export async function buildFilesContainer(
eventHistory
);

const filePlaceholderConverter = new FilePlaceholderConverter(
localFileSystem
);

const fileSyncStatusUpdater = new FileSyncStatusUpdater(localFileSystem);

const fileSyncronizer = new FileSyncronizer(
repository,
fileSyncStatusUpdater,
filePlaceholderConverter,
fileCreator,
sharedContainer.absolutePathToRelativeConverter,
folderContainer.folderCreator,
folderContainer.offline.folderCreator,
folderContainer.foldersFatherSyncStatusUpdater
);

const container: FilesContainer = {
fileFinderByContentsId,
fileDeleter,
filePathUpdater,
fileCreator,
fileFolderContainerDetector,
fileSyncronizer,
filePlaceholderCreatorFromContentsId: filePlaceholderCreatorFromContentsId,
createFilePlaceholderOnDeletionFailed:
createFilePlaceholderOnDeletionFailed,
Expand All @@ -135,6 +156,8 @@ export async function buildFilesContainer(
repositoryPopulator: repositoryPopulator,
filesPlaceholderCreator,
filesPlaceholderUpdater,
filePlaceholderConverter,
fileSyncStatusUpdater,
};

return { container, subscribers: [] };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import { RetryFolderDeleter } from '../../../../context/virtual-drive/folders/ap
import { SynchronizeOfflineModifications } from '../../../../context/virtual-drive/folders/application/SynchronizeOfflineModifications';
import { SynchronizeOfflineModificationsOnFolderCreated } from '../../../../context/virtual-drive/folders/application/SynchronizeOfflineModificationsOnFolderCreated';
import { FolderPlaceholderUpdater } from '../../../../context/virtual-drive/folders/application/UpdatePlaceholderFolder';
import { FolderPlaceholderConverter } from '../../../../context/virtual-drive/folders/application/FolderPlaceholderConverter';
import { FolderSyncStatusUpdater } from '../../../../context/virtual-drive/folders/application/FolderSyncStatusUpdater';
import { FoldersFatherSyncStatusUpdater } from '../../../../context/virtual-drive/folders/application/FoldersFatherSyncStatusUpdater';

export interface FoldersContainer {
folderCreator: FolderCreator;
Expand All @@ -34,4 +37,7 @@ export interface FoldersContainer {
folderRepositoryInitiator: FolderRepositoryInitiator;
folderPlaceholderUpdater: FolderPlaceholderUpdater;
foldersPlaceholderCreator: FoldersPlaceholderCreator;
folderPlaceholderConverter: FolderPlaceholderConverter;
folderSyncStatusUpdater: FolderSyncStatusUpdater;
foldersFatherSyncStatusUpdater: FoldersFatherSyncStatusUpdater;
}
Loading

0 comments on commit f0678a1

Please sign in to comment.