Skip to content

Commit

Permalink
fix: BUG when downloading the same file in one program for more than …
Browse files Browse the repository at this point in the history
…twice.
  • Loading branch information
AsakusaRinne committed Apr 23, 2024
1 parent 4c31ed4 commit f2e9a5d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
8 changes: 6 additions & 2 deletions HuggingfaceHub/HFDownloader.DownloadFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static async Task<string> DownloadFileAsync(string repoId, string filenam
// shortcut everything.
if(HFGlobalConfig.CommitHashRegex.IsMatch(revision)){
pointerPath = GetPointerPath(storageFolder, revision, relativeFilename);
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
if(Path.Exists(pointerPath)){
#else
if(File.Exists(pointerPath)){
Expand Down Expand Up @@ -615,7 +615,11 @@ private static void CreateSymlink(string src, string dst, bool newBlob = false){
try{
File.Delete(dst);
}
catch (Exception) { }
catch (Exception)
{
Logger?.LogWarning(dst + " already exists and cannot be overwritten. Skipped the file copy.");
return;
}

var absSrc = Path.GetFullPath(src);
var absDst = Path.GetFullPath(dst);
Expand Down
1 change: 0 additions & 1 deletion HuggingfaceHub/HFDownloader.DownloadSnapshot.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Diagnostics;
using Huggingface.Common;
using HuggingfaceHub;
using Microsoft.Extensions.Logging;

namespace Huggingface
Expand Down
22 changes: 21 additions & 1 deletion HuggingfaceHub/HuggingfaceHub.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,31 @@
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TargetFrameworks>net7.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net6;net7;net8;netstandard2.0</TargetFrameworks>
<LangVersion>12</LangVersion>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>

<Platforms>AnyCPU;x64;Arm64</Platforms>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<Version>0.1.1</Version>
<Authors>Rinne</Authors>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<RepositoryUrl>https://github.com/AsakusaRinne/HuggingfaceHub</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>Huggingface, Model, Download</PackageTags>
<PackageIconUrl>https://avatars.githubusercontent.com/u/25720743?s=200&amp;v=4</PackageIconUrl>
<Description>
HuggingfaceHub is a library to download models and files from Huggingface in .NET.
</Description>
<PackageOutputPath>packages</PackageOutputPath>
<PackageReadmeFile>README.md</PackageReadmeFile>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<None Include="..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
Expand Down
2 changes: 1 addition & 1 deletion HuggingfaceHub/IGroupedProgress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Text;
using System.Threading.Tasks;

namespace HuggingfaceHub
namespace Huggingface
{
/// <summary>
/// Progress callback when downloading multiple files
Expand Down

0 comments on commit f2e9a5d

Please sign in to comment.