mirror of
https://github.com/sasjs/core.git
synced 2026-01-04 08:00:05 +00:00
Merge pull request #315 from sasjs/allanbowe/hashing-file-breaks-mp-314
fix: ignoring empty files in mp_hashdirectory. Closes #314
This commit is contained in:
17
all.sas
17
all.sas
@@ -8659,7 +8659,7 @@ run;
|
|||||||
|
|
||||||
%put %sysfunc(hashing_file(md5,/path/to/file.blob,0));
|
%put %sysfunc(hashing_file(md5,/path/to/file.blob,0));
|
||||||
|
|
||||||
Usage:
|
Actual usage:
|
||||||
|
|
||||||
%let fpath=/some/directory;
|
%let fpath=/some/directory;
|
||||||
|
|
||||||
@@ -8681,6 +8681,7 @@ run;
|
|||||||
the folder hashes cascade upwards so you know immediately if there is a
|
the folder hashes cascade upwards so you know immediately if there is a
|
||||||
change in a sub/sub directory
|
change in a sub/sub directory
|
||||||
@li If the folder has no content (empty) then it is ignored. No hash created.
|
@li If the folder has no content (empty) then it is ignored. No hash created.
|
||||||
|
@li If the file is empty, it is also ignored / no hash created.
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mp_dirlist.sas
|
@li mp_dirlist.sas
|
||||||
@@ -8736,7 +8737,19 @@ data &outds;
|
|||||||
|
|
||||||
ts=datetime();
|
ts=datetime();
|
||||||
if file_or_folder='file' then do;
|
if file_or_folder='file' then do;
|
||||||
file_hash=hashing_file("&method",cats(file_path),0);
|
/* if file is empty, hashing_file will break - so ignore / delete */
|
||||||
|
length fname val $8;
|
||||||
|
drop fname val fid is_empty;
|
||||||
|
rc=filename(fname,file_path);
|
||||||
|
fid=fopen(fname);
|
||||||
|
if fid > 0 then do;
|
||||||
|
rc=fread(fid);
|
||||||
|
is_empty=fget(fid,val);
|
||||||
|
end;
|
||||||
|
rc=fclose(fid);
|
||||||
|
rc=filename(fname);
|
||||||
|
if is_empty ne 0 then delete;
|
||||||
|
else file_hash=hashing_file("&method",cats(file_path),0);
|
||||||
end;
|
end;
|
||||||
hash_duration=datetime()-ts;
|
hash_duration=datetime()-ts;
|
||||||
run;
|
run;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
%put %sysfunc(hashing_file(md5,/path/to/file.blob,0));
|
%put %sysfunc(hashing_file(md5,/path/to/file.blob,0));
|
||||||
|
|
||||||
Usage:
|
Actual usage:
|
||||||
|
|
||||||
%let fpath=/some/directory;
|
%let fpath=/some/directory;
|
||||||
|
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
the folder hashes cascade upwards so you know immediately if there is a
|
the folder hashes cascade upwards so you know immediately if there is a
|
||||||
change in a sub/sub directory
|
change in a sub/sub directory
|
||||||
@li If the folder has no content (empty) then it is ignored. No hash created.
|
@li If the folder has no content (empty) then it is ignored. No hash created.
|
||||||
|
@li If the file is empty, it is also ignored / no hash created.
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mp_dirlist.sas
|
@li mp_dirlist.sas
|
||||||
@@ -86,7 +87,19 @@ data &outds;
|
|||||||
|
|
||||||
ts=datetime();
|
ts=datetime();
|
||||||
if file_or_folder='file' then do;
|
if file_or_folder='file' then do;
|
||||||
file_hash=hashing_file("&method",cats(file_path),0);
|
/* if file is empty, hashing_file will break - so ignore / delete */
|
||||||
|
length fname val $8;
|
||||||
|
drop fname val fid is_empty;
|
||||||
|
rc=filename(fname,file_path);
|
||||||
|
fid=fopen(fname);
|
||||||
|
if fid > 0 then do;
|
||||||
|
rc=fread(fid);
|
||||||
|
is_empty=fget(fid,val);
|
||||||
|
end;
|
||||||
|
rc=fclose(fid);
|
||||||
|
rc=filename(fname);
|
||||||
|
if is_empty ne 0 then delete;
|
||||||
|
else file_hash=hashing_file("&method",cats(file_path),0);
|
||||||
end;
|
end;
|
||||||
hash_duration=datetime()-ts;
|
hash_duration=datetime()-ts;
|
||||||
run;
|
run;
|
||||||
|
|||||||
Reference in New Issue
Block a user