]> git.ipfire.org Git - pakfire.git/commitdiff
Copy packages to repository if we cannot hard-link them.
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 23 Feb 2011 21:46:37 +0000 (22:46 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 23 Feb 2011 21:46:37 +0000 (22:46 +0100)
pakfire/repository.py

index dc780c60596d86f878425ce3b5109d525dc80435..ff9a27904f37c3e7d5a81a8c24ed4d3a0e346450 100644 (file)
@@ -3,6 +3,7 @@
 import fnmatch
 import logging
 import os
+import shutil
 import stat
 import time
 
@@ -301,7 +302,12 @@ class LocalRepository(RepositoryFactory):
                        if not os.path.exists(repo_dirname):
                                os.makedirs(repo_dirname)
 
-                       os.link(pkg.filename, repo_filename)
+                       # Try to use a hard link if possible, if we cannot do that we simply
+                       # copy the file.
+                       try:
+                               os.link(pkg.filename, repo_filename)
+                       except OSError:
+                               shutil.copy2(pkg.filename, repo_filename)
 
                # Create new package object, that is connected to this repository
                # and so we can do stuff.