[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/native-comp 107514a 2/2: * Fix rename file error when reloading
From: |
Andrea Corallo |
Subject: |
feature/native-comp 107514a 2/2: * Fix rename file error when reloading the same file from an sys eln dir. |
Date: |
Thu, 10 Sep 2020 02:49:12 -0400 (EDT) |
branch: feature/native-comp
commit 107514a6e21f2c434cdae0eca76fe0a60e287ac8
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>
* Fix rename file error when reloading the same file from an sys eln dir.
* src/comp.c (Fnative_elisp_load): Don't rename files we don't
have the permission for.
---
src/comp.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/src/comp.c b/src/comp.c
index 5880224..4550833 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -4924,17 +4924,24 @@ DEFUN ("native-elisp-load", Fnative_elisp_load,
Snative_elisp_load, 1, 2, 0,
xsignal2 (Qnative_lisp_load_failed, build_string ("file does not exists"),
filename);
struct Lisp_Native_Comp_Unit *comp_u = allocate_native_comp_unit ();
- if (!NILP (Fgethash (filename, all_loaded_comp_units_h, Qnil)))
+
+ if (!NILP (Fgethash (filename, all_loaded_comp_units_h, Qnil))
+ && !NILP (Ffile_writable_p (filename)))
{
/* If in this session there was ever a file loaded with this
name rename before loading it to make sure we always get a
new handle! */
Lisp_Object tmp_filename =
- Fmake_temp_file_internal (filename, make_fixnum (0),
- build_string (".eln"), Qnil);
- Frename_file (filename, tmp_filename, Qnil);
- comp_u->handle = dynlib_open (SSDATA (tmp_filename));
- Frename_file (tmp_filename, filename, Qnil);
+ Fmake_temp_file_internal (filename, Qnil, build_string (".eln.tmp"),
+ Qnil);
+ if (NILP (Ffile_writable_p (tmp_filename)))
+ comp_u->handle = dynlib_open (SSDATA (filename));
+ else
+ {
+ Frename_file (filename, tmp_filename, Qt);
+ comp_u->handle = dynlib_open (SSDATA (tmp_filename));
+ Frename_file (tmp_filename, filename, Qnil);
+ }
}
else
comp_u->handle = dynlib_open (SSDATA (filename));