Ejemplo n.º 1
0
		internal override FileObjectDatabase.AlternateHandle[] MyAlternates()
		{
			FileObjectDatabase.AlternateHandle[] alt = alternates.Get();
			if (alt == null)
			{
				lock (alternates)
				{
					alt = alternates.Get();
					if (alt == null)
					{
						try
						{
							alt = LoadAlternates();
						}
						catch (IOException)
						{
							alt = new FileObjectDatabase.AlternateHandle[0];
						}
						alternates.Set(alt);
					}
				}
			}
			return alt;
		}
		internal override FileObjectDatabase.AlternateHandle[] MyAlternates()
		{
			if (alts == null)
			{
				FileObjectDatabase.AlternateHandle[] src = wrapped.MyAlternates();
				alts = new FileObjectDatabase.AlternateHandle[src.Length];
				for (int i = 0; i < alts.Length; i++)
				{
					FileObjectDatabase s = src[i].db;
					alts[i] = new FileObjectDatabase.AlternateHandle(s.NewCachedFileObjectDatabase());
				}
			}
			return alts;
		}
Ejemplo n.º 3
0
		/// <summary>Initialize a reference to an on-disk object directory.</summary>
		/// <remarks>Initialize a reference to an on-disk object directory.</remarks>
		/// <param name="cfg">configuration this directory consults for write settings.</param>
		/// <param name="dir">the location of the <code>objects</code> directory.</param>
		/// <param name="alternatePaths">a list of alternate object directories</param>
		/// <param name="fs">
		/// the file system abstraction which will be necessary to perform
		/// certain file system operations.
		/// </param>
		/// <exception cref="System.IO.IOException">an alternate object cannot be opened.</exception>
		public ObjectDirectory(Config cfg, FilePath dir, FilePath[] alternatePaths, FS fs
			)
		{
			config = cfg;
			objects = dir;
			infoDirectory = new FilePath(objects, "info");
			packDirectory = new FilePath(objects, "pack");
			alternatesFile = new FilePath(infoDirectory, "alternates");
			cachedPacksFile = new FilePath(infoDirectory, "cached-packs");
			packList = new AtomicReference<ObjectDirectory.PackList>(NO_PACKS);
			cachedPacks = new AtomicReference<ObjectDirectory.CachedPackList>();
			unpackedObjectCache = new UnpackedObjectCache();
			this.fs = fs;
			alternates = new AtomicReference<FileObjectDatabase.AlternateHandle[]>();
			if (alternatePaths != null)
			{
				FileObjectDatabase.AlternateHandle[] alt;
				alt = new FileObjectDatabase.AlternateHandle[alternatePaths.Length];
				for (int i = 0; i < alternatePaths.Length; i++)
				{
					alt[i] = OpenAlternate(alternatePaths[i]);
				}
				alternates.Set(alt);
			}
		}