MarkAsNoUnixFS() public static method

Sets a flag for a directory indicating that it resides on a non-Unix filesystem. This makes future calls to IsUnixFS run faster and more reliable.
There was an error writing the flag file. You have insufficient rights to write the flag file.
public static MarkAsNoUnixFS ( [ target ) : void
target [ The full path to the directory.
return void
Esempio n. 1
0
        public void TestIsUnixFS()
        {
            using (var tempDir = new TemporaryDirectory("0install-unit-tests"))
            {
                if (UnixUtils.IsUnix)
                {
                    FlagUtils.IsUnixFS(tempDir).Should().BeTrue();

                    FlagUtils.MarkAsNoUnixFS(tempDir);
                    FlagUtils.IsUnixFS(tempDir).Should().BeFalse();
                }
                else
                {
                    FlagUtils.IsUnixFS(tempDir).Should().BeFalse();
                }
            }
        }
Esempio n. 2
0
        public void TestIsUnixFS()
        {
            using (var tempDir = new TemporaryDirectory("0install-unit-tests"))
            {
                if (UnixUtils.IsUnix)
                {
                    Assert.IsTrue(FlagUtils.IsUnixFS(tempDir));

                    FlagUtils.MarkAsNoUnixFS(tempDir);
                    Assert.IsFalse(FlagUtils.IsUnixFS(tempDir));
                }
                else
                {
                    Assert.IsFalse(FlagUtils.IsUnixFS(tempDir));
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a new store using a specific path to a cache directory.
        /// </summary>
        /// <param name="path">A fully qualified directory path. The directory will be created if it doesn't exist yet.</param>
        /// <param name="useWriteProtection">Controls whether implementation directories are made write-protected once added to the cache to prevent unintentional modification (which would invalidate the manifest digests).</param>
        /// <exception cref="IOException">The directory <paramref name="path"/> could not be created or if the underlying filesystem can not store file-changed times accurate to the second.</exception>
        /// <exception cref="UnauthorizedAccessException">Creating the directory <paramref name="path"/> is not permitted.</exception>
        public DirectoryStore([NotNull] string path, bool useWriteProtection = true)
        {
            #region Sanity checks
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path");
            }
            #endregion

            try
            {
                DirectoryPath = Path.GetFullPath(path);
                if (!Directory.Exists(DirectoryPath))
                {
                    Directory.CreateDirectory(DirectoryPath);
                }
            }
            #region Error handling
            catch (ArgumentException ex)
            {
                // Wrap exception since only certain exception types are allowed
                throw new IOException(ex.Message, ex);
            }
            catch (NotSupportedException ex)
            {
                // Wrap exception since only certain exception types are allowed
                throw new IOException(ex.Message, ex);
            }
            #endregion

            Kind = DetermineKind(DirectoryPath);
            _useWriteProtection = useWriteProtection;
            _isUnixFS           = FlagUtils.IsUnixFS(DirectoryPath);

            if (Kind == StoreKind.ReadWrite)
            {
                if (!_isUnixFS)
                {
                    FlagUtils.MarkAsNoUnixFS(DirectoryPath);
                }
                if (_useWriteProtection && WindowsUtils.IsWindowsNT)
                {
                    WriteDeleteInfoFile(DirectoryPath);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a new store using a specific path to a cache directory.
        /// </summary>
        /// <param name="directoryPath">A fully qualified directory path. The directory will be created if it doesn't exist yet.</param>
        /// <param name="useWriteProtection">Controls whether implementation directories are made write-protected once added to the cache to prevent unintentional modification (which would invalidate the manifest digests).</param>
        /// <exception cref="IOException">The <paramref name="directoryPath"/> could not be created or the underlying filesystem can not store file-changed times accurate to the second.</exception>
        /// <exception cref="UnauthorizedAccessException">Creating the <paramref name="directoryPath"/> is not permitted.</exception>
        public DiskImplementationStore(string directoryPath, bool useWriteProtection = true)
        {
            #region Sanity checks
            if (string.IsNullOrEmpty(directoryPath))
            {
                throw new ArgumentNullException(nameof(directoryPath));
            }
            #endregion

            try
            {
                DirectoryPath = Path.GetFullPath(directoryPath);
                if (!Directory.Exists(DirectoryPath))
                {
                    Directory.CreateDirectory(DirectoryPath);
                }
            }
            #region Error handling
            catch (ArgumentException ex)
            {
                // Wrap exception since only certain exception types are allowed
                throw new IOException(ex.Message, ex);
            }
            catch (NotSupportedException ex)
            {
                // Wrap exception since only certain exception types are allowed
                throw new IOException(ex.Message, ex);
            }
            #endregion

            Kind = DetermineKind(DirectoryPath);
            _useWriteProtection = useWriteProtection;
            _isUnixFS           = FlagUtils.IsUnixFS(DirectoryPath);

            if (Kind == ImplementationStoreKind.ReadWrite)
            {
                try
                {
                    if (!_isUnixFS)
                    {
                        FlagUtils.MarkAsNoUnixFS(DirectoryPath);
                    }
                    if (_useWriteProtection && WindowsUtils.IsWindowsNT)
                    {
                        WriteDeleteInfoFile(DirectoryPath);
                    }
                }
                #region Error handling
                catch (IOException ex)
                {
                    // Writing these files is not critical
                    Log.Debug(ex);
                }
                catch (UnauthorizedAccessException ex)
                {
                    // Writing these files is not critical
                    Log.Debug(ex);
                }
                #endregion
            }
        }