Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-filestorage
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project-open
intranet-filestorage
Commits
f1af04a6
Commit
f1af04a6
authored
Apr 09, 2017
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Updated intranet-filestorage
replacing exec by im_exec and doing some testing on Linux
parent
f903548e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
56 additions
and
83 deletions
+56
-83
intranet-filestorage-procs.tcl
tcl/intranet-filestorage-procs.tcl
+34
-53
action.tcl
www/action.tcl
+13
-18
create-folder-2.tcl
www/create-folder-2.tcl
+1
-2
delete.tcl
www/delete.tcl
+1
-1
upload-2.tcl
www/upload-2.tcl
+3
-4
upload-zip-2.tcl
www/upload-zip-2.tcl
+4
-5
No files found.
tcl/intranet-filestorage-procs.tcl
View file @
f1af04a6
...
...
@@ -70,7 +70,13 @@ ad_proc -public im_filestorage_find_cmd {} {
Returns the Unix/Linux/Windows find command as specified in the
intranet-core.FindCmd command
}
{
return
[
util_memoize im_filestorage_find_cmd_helper 3600
]
}
ad_proc -public im_filestorage_find_cmd_helper
{}
{
Returns the Unix/Linux/Windows find command as specified in the
intranet-core.FindCmd command
}
{
# -------------------------------------------------
# First check for a default value for each platform:
global tcl_platform
...
...
@@ -92,7 +98,7 @@ ad_proc -public im_filestorage_find_cmd {} {
# Just run find on itself - this should return exactly one file
set winaoldir
$::env
(
AOLDIR
)
set unixaoldir
[
string
map
{
\\
/
}
${winaoldir}
]
set file_list
[
exec
$find
_cmd
${unixaoldir}
/bin/$
{
find_cmd
}
.exe -maxdepth 0
]
set file_list
[
im_
exec
$find
_cmd
${unixaoldir}
/bin/$
{
find_cmd
}
.exe -maxdepth 0
]
}
err_msg
]}
{
return
$find
_cmd
}
...
...
@@ -106,7 +112,7 @@ ad_proc -public im_filestorage_find_cmd {} {
if
{
!
[
catch
{
# Just run find on itself - this should return exactly one file
set file_list
[
exec
$find
_cmd
$find
_cmd -maxdepth 0
]
set file_list
[
im_
exec
$find
_cmd
$find
_cmd -maxdepth 0
]
}
err_msg
]}
{
return
$find
_cmd
}
...
...
@@ -119,7 +125,7 @@ ad_proc -public im_filestorage_find_cmd {} {
if
{
[
catch
{
# Just run find on itself - this should return exactly one file
set file_list
[
exec
$find
_cmd
$find
_cmd -maxdepth 0
]
set file_list
[
im_
exec
$find
_cmd
$find
_cmd -maxdepth 0
]
}
err_msg
]}
{
ad_return_complaint 1
"<B>Configuration Error</b>:
...
...
@@ -300,8 +306,6 @@ proc intranet_download { folder_type } {
}
ad_proc -public im_package_filestorage_id
{
}
{
}
{
return
[
util_memoize im_package_filestorage_id_helper
]
...
...
@@ -356,17 +360,17 @@ ad_proc -public im_filestorage_find_files { project_id } {
}
{
set project_path
[
im_filestorage_project_path
$project
_id
]
set find_cmd
[
im_filestorage_find_cmd
]
if
{
[
catch
{
ns_log Notice
"im_filestorage_find_files: Checking
$project
_path"
exec /bin/mkdir -p
$project
_path
exec /bin/
chmod ug+w
$project
_path
set file_list
[
exec
$find
_cmd
$project
_path -noleaf -type f
]
file mkdir
$project
_path
im_exec
chmod ug+w
$project
_path
set file_list
[
im_
exec
$find
_cmd
$project
_path -noleaf -type f
]
}
err_msg
]
}
{
# Probably some permission errors - return empty string
set err
"'exec
$find
_cmd
$project
_path -noleaf -type f' failed with error:
err_msg=
$err
_msg
\n
"
ns_log Error
"im_filestorage_find_files: 'file mkdir
$project
_path; chmod ug+w
$project
_path;
$find
_cmd
$project
_path -noleaf -type f' failed with error: err_msg=
$err
_msg
\n
"
set file_list
""
}
...
...
@@ -1000,10 +1004,8 @@ ad_proc im_filestorage_copy_source_directory { project_id sub_project_id } {
if
{
""
!=
$source
_language
}
{
ns_log Notice
"im_filestorage_copy_directory:
$source
_dir ->
$sub
_source_dir"
if
{[
catch
{
ns_log Notice
"im_filestorage_copy_source_directory: exec /bin/cp -r
$source
_dir/*
$sub
_source_dir/"
exec /bin/cp -r
"
$source
_dir"
"
$sub
_source_dir"
ns_log Notice
"im_filestorage_copy_source_directory: im_exec cp -r
$source
_dir/*
$sub
_source_dir/"
im_exec cp -r
"
$source
_dir"
"
$sub
_source_dir"
}
err_msg
]}
{
return
$err
_msg
}
}
...
...
@@ -1063,10 +1065,9 @@ where
ns_log Notice
"im_filestorage_create_directories: company_dir=
$company
_dir"
if
{
[
catch
{
if
{
!
[
file
exists
$company
_dir
]}
{
ns_log Notice
"exec /bin/mkdir -p
$company
_dir"
exec /bin/mkdir -p
$company
_dir
ns_log Notice
"exec /bin/chmod ug+w
$company
_dir"
exec /bin/chmod ug+w
$company
_dir
file mkdir
$company
_dir
ns_log Notice
"im_exec chmod ug+w
$company
_dir"
im_exec chmod ug+w
$company
_dir
}
}
err_msg
]
}
{
return
$err
_msg
}
...
...
@@ -1075,10 +1076,9 @@ where
ns_log Notice
"im_filestorage_create_directories: project_dir=
$project
_dir"
if
{
[
catch
{
if
{
!
[
file
exists
$project
_dir
]}
{
ns_log Notice
"exec /bin/mkdir -p
$project
_dir"
exec /bin/mkdir -p
$project
_dir
ns_log Notice
"exec /bin/chmod ug+w
$project
_dir"
exec /bin/chmod ug+w
$project
_dir
file mkdir
$project
_dir
ns_log Notice
"im_exec chmod ug+w
$project
_dir"
im_exec chmod ug+w
$project
_dir
}
}
err_msg
]}
{
return
$err
_msg
}
...
...
@@ -1088,10 +1088,9 @@ where
ns_log Notice
"im_filestorage_create_directories: source_dir=
$source
_dir"
if
{[
catch
{
if
{
!
[
file
exists
$source
_dir
]}
{
ns_log Notice
"exec /bin/mkdir -p
$source
_dir"
exec /bin/mkdir -p
$source
_dir
ns_log Notice
"exec /bin/chmod ug+w
$source
_dir"
exec /bin/chmod ug+w
$source
_dir
file mkdir
$source
_dir
ns_log Notice
"im_exec chmod ug+w
$source
_dir"
im_exec chmod ug+w
$source
_dir
}
}
err_msg
]}
{
return
$err
_msg
...
...
@@ -1104,10 +1103,9 @@ where
ns_log Notice
"im_filestorage_create_directories: source_dir=
$source
_dir"
if
{[
catch
{
if
{
!
[
file
exists
$source
_dir
]}
{
ns_log Notice
"exec /bin/mkdir -p
$source
_dir"
exec /bin/mkdir -p
$source
_dir
ns_log Notice
"exec /bin/chmod ug+w
$source
_dir"
exec /bin/chmod ug+w
$source
_dir
file mkdir
$source
_dir
ns_log Notice
"im_exec chmod ug+w
$source
_dir"
im_exec chmod ug+w
$source
_dir
}
}
err_msg
]}
{
return
$err
_msg
}
}
...
...
@@ -1128,10 +1126,9 @@ where
ns_log Notice
"im_filestorage_create_directories: dir=
$dir
"
if
{
!
[
file
exists
$dir
]}
{
if
{[
catch
{
ns_log Notice
"exec /bin/mkdir -p
$dir
"
exec /bin/mkdir -p
$dir
ns_log Notice
"exec /bin/chmod ug+w
$dir
"
exec /bin/chmod ug+w
$dir
file mkdir
$dir
ns_log Notice
"im_exec chmod ug+w
$dir
"
im_exec chmod ug+w
$dir
}
err_msg
]
}
{
return
$err
_msg
}
}
...
...
@@ -1615,9 +1612,9 @@ ad_proc -public im_filestorage_base_component { user_id object_id object_name ba
if
{
[
catch
{
# Executing the find command
exec /bin/mkdir -p
$find
_path
exec /bin/
chmod ug+w
$find
_path
set file_list
[
exec
$find
_cmd
$find
_path -noleaf
]
file mkdir
$find
_path
im_exec
chmod ug+w
$find
_path
set file_list
[
im_
exec
$find
_cmd
$find
_path -noleaf
]
set files
[
lsort
[
split
$file
_list
"
\n
"
]]
}
err_msg
]
}
{
...
...
@@ -2157,14 +2154,6 @@ ad_proc im_filestorage_file_type_icon {ext} {
}
ad_proc im_filestorage_create_folder
{
folder folder_name
}
{
Create a new folder
}
{
if
{
[
catch
{
exec mkdir
$folder
/$folder_name
}
err_msg
]
}
{
return
$err
_msg
}
}
ad_proc im_filestorage_is_directory_empty
{
folder
}
{
}
{
...
...
@@ -2205,14 +2194,6 @@ ad_proc im_filestorage_delete_folder {project_id folder_id folder} {
}
err_msg
]
}
{
return
$err
_msg
}
}
ad_proc im_filestorage_erase_files
{
project_id file_name
}
{
}
{
if
{
[
catch
{
exec rm
$file
_name
}
err_msg
]
}
{
return
$err
_msg
}
}
# -------------------------------------------------------
...
...
www/action.tcl
View file @
f1af04a6
...
...
@@ -350,21 +350,20 @@ switch $actions {
# Get folders with read permission
set dest_path
{}
set folder_sql
"
select
f.path as folder_path
from
im_fs_folder_perms p,
select f.path as folder_path
from im_fs_folder_perms p,
im_fs_folders f
where
f.object_id = :object_id
where f.object_id = :object_id
and p.folder_id = f.folder_id
and p.profile_id in (
[
join
$user
_memberships
", "
]
)
and p.read_p = '1'
"
db_foreach get_folders
$folder
_sql
{
lappend dest_path
"
$base
_path/
$folder
_path"
set path
"
$base
_path/
$folder
_path"
if
{
!
[
file
readable
$path
]}
{
continue
}
lappend dest_path
$path
}
# Permissions for all usual projects, companies etc.
set object_type
[
db_string acs_object_type
"select object_type from acs_objects where object_id=:object_id"
]
set perm_cmd
"
${object_type}
_permissions
\$
user_id
\$
object_id object_view object_read object_write object_admin"
...
...
@@ -407,7 +406,6 @@ switch $actions {
ad_script_abort
}
# Determine a random .tgz zip_file
set r
[
ns_rand 10000000
]
set zip_file
"zip.
$user
_id.
$r.tgz
"
...
...
@@ -417,17 +415,18 @@ switch $actions {
set tmp_path
[
im_filestorage_tmp_path
]
set zip_file_path
"
$tmp
_path/
$zip
_file"
# build exec command
set tar_command
"/bin/tar czf
$zip
_file_path"
# build
im_
exec command
set tar_command
[
list
im_exec tar czf
$zip
_file_path -P
]
foreach path
$dest
_path
{
lappend tar_command
$path
}
if
{
[
catch
{
ns_log Notice
"intranet-filestorage/action: zip: About to execute tar_command=
$tar
_command"
eval
"exec
[
join
$tar
_command
]
"
eval
$tar
_command
}
err_msg
]
}
{
ns_log Error
"------>
$err
_msg"
ns_log Error
"intranet-filestorage/action: Error executing '
$tar
_command':
$err
_msg"
ad_return_complaint 1
"intranet-filestorage/action: <br>Error executing '
$tar
_command':
$err
_msg"
# Nothing. We check if TAR was successfull if the file exists.
}
...
...
@@ -577,6 +576,7 @@ switch $actions {
ad_returnredirect
"
$url
_base?
[
export_url_bind_vars
$bind
_vars
]
"
}
"del"
{
# --------------------- Delete ---------------------
...
...
@@ -686,10 +686,5 @@ foreach var [ad_ns_set_keys $bind_vars] {
}
append
vars
"url_base=
$url
_base
\n
"
db_release_unused_handles
ad_return_complaint 1
"<pre>
$vars
</pre>"
return
set
page_title
"
[
_ intranet-filestorage.lt_Upload_into_my_folder
]
"
www/create-folder-2.tcl
View file @
f1af04a6
...
...
@@ -51,9 +51,8 @@ append base_path $bread_crum_path
set
char_style
[
parameter::get -package_id
[
im_package_filestorage_id
]
-parameter
"FilenameCharactersSupported"
-default
"none"
]
set
folder_name
[
im_l10n_normalize_string -style
$char
_style
$folder
_name
]
set
err_msg
[
im_filestorage_create_folder
$base
_path
$folder
_name
]
file
mkdir
"
$base
_path/
$folder
_name"
db_release_unused_handles
ad_returnredirect
$return
_url
...
...
www/delete.tcl
View file @
f1af04a6
...
...
@@ -73,7 +73,7 @@ foreach id [array names file_id] {
return
}
set erase
[
im_filestorage_erase_files
$object
_id
$base
_path/$id_path
(
$id
)]
im_exec rm
"
$base
_path/
$id
_path(
$id
)"
}
...
...
www/upload-2.tcl
View file @
f1af04a6
...
...
@@ -148,10 +148,9 @@ set dest_path "$base_path/$bread_crum_path/$client_filename"
ns_log Notice
"dest_path=
$dest
_path"
if
{
[
catch
{
ns_log Notice
"/bin/mv
$tmp
_filename
$dest
_path"
exec /bin/cp
$tmp
_filename
$dest
_path
ns_log Notice
"/bin/chmod ug+w
$dest
_path"
exec /bin/chmod ug+w
$dest
_path
file copy -force --
$tmp
_filename
$dest
_path
ns_log Notice
"chmod ug+w
$dest
_path"
im_exec chmod ug+w
$dest
_path
}
err_msg
]
}
{
# Probably some permission errors
ad_return_complaint
"Error writing upload file"
$err
_msg
...
...
www/upload-zip-2.tcl
View file @
f1af04a6
...
...
@@ -131,12 +131,11 @@ set dest_path "$base_path/$bread_crum_path"
ns_log Notice
"upload-zip-2: dest_path=
$dest
_path"
ns_log Notice
"upload-zip-2: tmp_filename=
$tmp
_filename"
if
{
[
catch
{
ns_log Notice
{
upload-zip-2: /bin/bash -c
"cd
$dest
_path; unzip -oL
$tmp
_filename"
}
set unzip_result
[
exec
/bin/
bash -c
"cd
$dest
_path; unzip -oL
$tmp
_filename"
]
ns_log Notice
"upload-zip-2:
/bin/
chmod ug+w
$dest
_path"
exec /bin/
chmod ug+w
$dest
_path
ns_log Notice
"upload-zip-2: bash -c 'cd
$dest
_path; unzip -oL
$tmp
_filename'"
set unzip_result
[
im_exec
bash -c
"cd
$dest
_path; unzip -oL
$tmp
_filename"
]
ns_log Notice
"upload-zip-2: chmod ug+w
$dest
_path"
im_exec
chmod ug+w
$dest
_path
}
err_msg
]
}
{
# Probably some permission errors
ad_return_complaint 1
"Error writing upload file:<br><pre>
$err
_msg</pre>"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment