示例#1
0
        private void Write()
        {
            // Write to a .tmp file
            File tmpFile = _dbDirectoryStructure.file(_tmpIndexDbFileName);

            Write(tmpFile);

            // Make sure the .old file doesn't exist, then rename the current one to .old
            _fileSystem.deleteFile(_oldFile);
            try
            {
                if (_fileSystem.fileExists(_file))
                {
                    _fileSystem.renameFile(_file, _oldFile);
                }
            }
            catch (IOException e)
            {
                throw new Exception("Couldn't rename " + _file + " -> " + _oldFile, e);
            }

            // Rename the .tmp file to the current name
            try
            {
                _fileSystem.renameFile(tmpFile, this._file);
            }
            catch (IOException e)
            {
                throw new Exception("Couldn't rename " + tmpFile + " -> " + _file, e);
            }
            _fileSystem.deleteFile(_oldFile);
        }
示例#2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void delete(java.io.File storeDir, org.neo4j.kernel.impl.transaction.log.files.LogFiles logFiles) throws java.io.IOException
        public virtual void Delete(File storeDir, LogFiles logFiles)
        {
            // 'files' can be null if the directory doesn't exist. This is fine, we just ignore it then.
            File[] files = _fs.listFiles(storeDir, _fileFilter);
            if (files != null)
            {
                foreach (File file in files)
                {
                    _fs.deleteRecursively(file);
                }
            }

            File[] txLogs = _fs.listFiles(logFiles.LogFilesDirectory());
            if (txLogs != null)
            {
                foreach (File txLog in txLogs)
                {
                    _fs.deleteFile(txLog);
                }
            }

            IEnumerable <FileHandle> iterator = AcceptedPageCachedFiles(storeDir).iterator;

            foreach (FileHandle fh in iterator)
            {
                fh.Delete();
            }
        }
示例#3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: void clearIdFiles(java.nio.file.Path backupLocation) throws java.io.IOException
        internal virtual void ClearIdFiles(Path backupLocation)
        {
            IOException exception       = null;
            File        targetDirectory = backupLocation.toFile();

            File[] files = _fs.listFiles(targetDirectory);
            foreach (File file in files)
            {
                if (!_fs.isDirectory(file) && file.Name.EndsWith(".id"))
                {
                    try
                    {
                        long highId = IdGeneratorImpl.readHighId(_fs, file);
                        _fs.deleteFile(file);
                        IdGeneratorImpl.createGenerator(_fs, file, highId, true);
                    }
                    catch (IOException e)
                    {
                        exception = Exceptions.chain(exception, e);
                    }
                }
            }
            if (exception != null)
            {
                throw exception;
            }
        }
示例#4
0
 /// <summary>
 /// Delete failure file for the given index id
 ///
 /// </summary>
 public virtual void ClearForIndex()
 {
     lock (this)
     {
         _fs.deleteFile(FailureFile());
     }
 }
示例#5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public synchronized void closeAndDelete() throws java.io.IOException
        public override void CloseAndDelete()
        {
            lock (this)
            {
                Close();
                _fs.deleteFile(_file);
            }
        }
示例#6
0
            public override void Accept(long version)
            {
                FromVersion = FromVersion == NO_VERSION ? version : Math.Min(FromVersion, version);
                ToVersion   = ToVersion == NO_VERSION ? version : Math.Max(ToVersion, version);
                File logFile = LogFiles.getLogFileForVersion(version);

                Fs.deleteFile(logFile);
            }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void streamFilesRecursiveMustThrowWhenDeletingNonExistingFile() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void StreamFilesRecursiveMustThrowWhenDeletingNonExistingFile()
        {
            File       a      = ExistingFile("a");
            FileHandle handle = Fsa.streamFilesRecursive(a).findAny().get();

            Fsa.deleteFile(a);
            assertThrows(typeof(NoSuchFileException), handle.delete);
        }
示例#8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void purge() throws java.io.IOException
        public override void Purge()
        {
            base.Purge();               // Clears all cached data

            // Delete the file
            if (!_fileSystem.deleteFile(_authFile))
            {
                throw new IOException("Failed to delete file '" + _authFile.AbsolutePath + "'");
            }
        }
示例#9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void upgradedNeoStoreShouldHaveNewUpgradeTimeAndUpgradeId() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UpgradedNeoStoreShouldHaveNewUpgradeTimeAndUpgradeId()
        {
            // Given
            _fileSystem.deleteFile(_databaseLayout.file(INTERNAL_LOG_FILE));
            PageCache          pageCache          = _pageCacheRule.getPageCache(_fileSystem);
            UpgradableDatabase upgradableDatabase = GetUpgradableDatabase(pageCache);

            // When
            NewUpgrader(upgradableDatabase, _allowMigrateConfig, pageCache).migrateIfNeeded(_databaseLayout);

            // Then
            StoreFactory factory = new StoreFactory(_databaseLayout, _allowMigrateConfig, new DefaultIdGeneratorFactory(_fileSystem), pageCache, _fileSystem, NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);

            using (NeoStores neoStores = factory.OpenAllNeoStores())
            {
                assertThat(neoStores.MetaDataStore.UpgradeTransaction, equalTo(neoStores.MetaDataStore.LastCommittedTransaction));
                assertThat(neoStores.MetaDataStore.UpgradeTime, not(equalTo(MetaDataStore.FIELD_NOT_INITIALIZED)));

                long minuteAgo = DateTimeHelper.CurrentUnixTimeMillis() - MINUTES.toMillis(1);
                assertThat(neoStores.MetaDataStore.UpgradeTime, greaterThan(minuteAgo));
            }
        }
示例#10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void shiftArchivedOutputFiles() throws java.io.IOException
        private void ShiftArchivedOutputFiles()
        {
            for (int i = LastArchivedOutputFileNumber(_fileSystem, _outputFile); i > 0; --i)
            {
                File archive = ArchivedOutputFile(_outputFile, i);
                if (i >= _maxArchives)
                {
                    _fileSystem.deleteFile(archive);
                }
                else
                {
                    _fileSystem.renameFile(archive, ArchivedOutputFile(_outputFile, i + 1));
                }
            }
        }
示例#11
0
        private void RemoveEmptyParent(File parentFile)
        {
            // delete up to and including the base directory, but not above.
            // Note that this may be 'null' if 'baseDirectory' is the top directory.
            // Fortunately, 'File.equals(other)' handles 'null' and returns 'false' when 'other' is 'null'.
            File end = _baseDirectory.ParentFile;

            while (parentFile != null && !parentFile.Equals(end))
            {
                File[] files = _fs.listFiles(parentFile);
                if (files == null || Files.Length > 0)
                {
                    return;
                }
                _fs.deleteFile(parentFile);
                parentFile = parentFile.ParentFile;
            }
        }
示例#12
0
 public virtual bool Delete()
 {
     return(_fileSystem.deleteFile(_file));
 }
示例#13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void before()
        public virtual void Before()
        {
            when(_fsa.deleteFile(any())).thenReturn(true);
        }