/// <summary> /// costruttore /// </summary> /// <param name="path">path della cartella da monitorare</param> public DirMonitor(string path, SessionManager sm) { myDir = new System.IO.DirectoryInfo(path); if (!myDir.Exists) { throw new System.IO.DirectoryNotFoundException(path); } try { dim = new DirImageManager(myDir, sm); } catch (InitialBackupNeededException ibne) { //TODO! ATTENZIONE, COME INTERROMPO L'APPLICAZIONE METRE STA FACENDO L'INITIAL BACKUP ????? al momento solo tra un file e l'altro //non c'è ancora nessun backup sul server, impossibile scaricare una dirImage. //devo fare un initial backup completo. terminato quello bisogna riscaricare la dirImage completeFileList = new List <RecordFile>(); //salvo vecchio delegato var buf = this.doOnFile; this.doOnFile = addAllFiles; //crea elenco completo file in root dir e subdirs WalkDirectoryTree(myDir, doOnFile); //rimetto delegato di prima this.doOnFile = buf; //effettua backup completo di tutti i file sm.sendInitialBackup(completeFileList); completeFileList = null; //se la cartella è vuota la new DirImageManager continua a fallire, viene rilanciata l'eccezione InitialBackupNeededException try { //riscarico la dirImage dim = new DirImageManager(myDir, sm); } catch (InitialBackupNeededException) { throw new EmptyDirException(); } } doOnFile = checkFile; init(); }
/// <summary> /// costruttore /// </summary> /// <param name="path">path della cartella da monitorare</param> public DirMonitor(string path, SessionManager sm) { myDir = new System.IO.DirectoryInfo(path); if (!myDir.Exists) throw new System.IO.DirectoryNotFoundException(path); try { dim = new DirImageManager(myDir, sm); } catch(InitialBackupNeededException ibne) { //TODO! ATTENZIONE, COME INTERROMPO L'APPLICAZIONE METRE STA FACENDO L'INITIAL BACKUP ????? al momento solo tra un file e l'altro //non c'è ancora nessun backup sul server, impossibile scaricare una dirImage. //devo fare un initial backup completo. terminato quello bisogna riscaricare la dirImage completeFileList = new List<RecordFile>(); //salvo vecchio delegato var buf = this.doOnFile; this.doOnFile = addAllFiles; //crea elenco completo file in root dir e subdirs WalkDirectoryTree(myDir, doOnFile); //rimetto delegato di prima this.doOnFile = buf; //effettua backup completo di tutti i file sm.sendInitialBackup(completeFileList); completeFileList = null; //se la cartella è vuota la new DirImageManager continua a fallire, viene rilanciata l'eccezione InitialBackupNeededException try { //riscarico la dirImage dim = new DirImageManager(myDir, sm); } catch (InitialBackupNeededException) { throw new EmptyDirException(); } } doOnFile = checkFile; init(); }