| |
1 |
1 |
# packages/static-pages/tcl/static-pages-procs.tcl |
| |
2 |
2 |
ad_library { |
| |
3 |
3 |
Utilities for static pages. |
| |
4 |
4 |
|
| |
5 |
5 |
@author Brandoch Calef (bcalef@arsdigita.com) |
| |
6 |
6 |
@creation-date 2001-01-22 |
| |
7 |
7 |
@cvs-id $Id$ |
| |
8 |
8 |
} |
| |
9 |
9 |
|
| |
10 |
10 |
|
| |
|
11 |
ad_proc -public sp_sync_cr_with_filesystem_scheduled {{}} { |
| |
|
12 |
|
| |
|
13 |
Sync the filesystem and the content repository in a scheduled |
| |
|
14 |
procedure, rather than manually. Calls sp_sync_cr_with_filesystem |
| |
|
15 |
just like the www/admin/fs-scan-progress.tcl page does. |
| |
|
16 |
|
| |
|
17 |
<p> |
| |
|
18 |
Note that if you have comments turned on, be <em>very carefull</em> |
| |
|
19 |
running this, as the current implementation of |
| |
|
20 |
sp_sync_cr_with_filesystem will <em>destroy</em> any user |
| |
|
21 |
contributed comments on the file if you temporarily delete the |
| |
|
22 |
file, then run that procedure. |
| |
|
23 |
|
| |
|
24 |
@author Andrew Piskorski (atp@piskorski.com) |
| |
|
25 |
@creation-date 2002/09/12 |
| |
|
26 |
} { |
| |
|
27 |
set proc_name {sp_sync_cr_with_filesystem_scheduled} |
| |
|
28 |
ns_log Notice "$proc_name: Starting." |
| |
|
29 |
|
| |
|
30 |
# sp_sync_cr_with_filesystem callbacks to fill file_items with info: |
| |
|
31 |
|
| |
|
32 |
proc sp_sch_old_item { path id } {} |
| |
|
33 |
proc sp_sch_new_item { path id } {} |
| |
|
34 |
proc sp_sch_changed_item { path id } { |
| |
|
35 |
# The title may have changed: |
| |
|
36 |
sp_flush_page $id |
| |
|
37 |
} |
| |
|
38 |
|
| |
|
39 |
# TODO: We can have more than one package instance, so must decide |
| |
|
40 |
# here WHICH package instance to run the sync for. This should |
| |
|
41 |
# probably be something configurable for each package instance from |
| |
|
42 |
# the admin page, but for now we simply find and sync ALL package |
| |
|
43 |
# instances: --atp@piskorski.com, 2002/09/12 14:02 EDT |
| |
|
44 |
|
| |
|
45 |
set package_key [sp_package_key_is] |
| |
|
46 |
|
| |
|
47 |
db_foreach each_apm_package_instance { |
| |
|
48 |
select package_id, instance_name |
| |
|
49 |
from apm_packages |
| |
|
50 |
where package_key = :package_key |
| |
|
51 |
order by package_id |
| |
|
52 |
} { |
| |
|
53 |
set root_folder_id [sp_root_folder_id $package_id] |
| |
|
54 |
set fs_root "[acs_root_dir][ad_parameter -package_id $package_id {fs_root}]" |
| |
|
55 |
|
| |
|
56 |
ns_log Notice "$proc_name: About to scan the filesystem for: package_id '$package_id', instance_name '$instance_name', fs_root '$fs_root':" |
| |
|
57 |
|
| |
|
58 |
# If our call to sp_sync_cr_with_filesystem fails for some |
| |
|
59 |
# reason, want to continue on trying the other package |
| |
|
60 |
# instances: |
| |
|
61 |
|
| |
|
62 |
set sync_proc {sp_sync_cr_with_filesystem} |
| |
|
63 |
if { [catch { |
| |
|
64 |
set result [$sync_proc -package_id $package_id \ |
| |
|
65 |
-file_unchanged_proc sp_sch_old_item \ |
| |
|
66 |
-file_add_proc sp_sch_new_item \ |
| |
|
67 |
-file_change_proc sp_sch_changed_item \ |
| |
|
68 |
-folder_add_proc sp_sch_new_item \ |
| |
|
69 |
-folder_unchanged_proc sp_sch_old_item \ |
| |
|
70 |
$fs_root $root_folder_id] |
| |
|
71 |
} errmsg] } { |
| |
|
72 |
global errorInfo |
| |
|
73 |
ns_log Error "$proc_name: For package_id: '$package_id', $sync_proc failed with error:\n${errorInfo}" |
| |
|
74 |
} else { |
| |
|
75 |
ns_log Notice "$proc_name: For package_id: '$package_id': $result" |
| |
|
76 |
} |
| |
|
77 |
|
| |
|
78 |
} if_no_rows { |
| |
|
79 |
ns_log Warning "$proc_name: NO package ids found for package key: '$package_key'." |
| |
|
80 |
} |
| |
|
81 |
|
| |
|
82 |
ns_log Notice "$proc_name: Done." |
| |
|
83 |
} |
| |
|
84 |
|
| |
|
85 |
|
| |
11 |
86 |
ad_proc -public sp_sync_cr_with_filesystem { |
| |
12 |
87 |
{ |
| |
13 |
88 |
-file_add_proc "" |
| |
14 |
89 |
-file_change_proc "" |
| |
15 |
90 |
-file_unchanged_proc "" |
| |
16 |
91 |
-file_read_error_proc "" |
| |
17 |
92 |
-folder_add_proc "" |
| |
18 |
93 |
-folder_unchanged_proc "" |
| |
19 |
94 |
-package_id "" |
| |
20 |
95 |
} |
| |
21 |
96 |
fs_root |
| |
22 |
97 |
root_folder_id |
| |
23 |
98 |
{ |
| |
24 |
99 |
static_page_regexp {} |
| |
25 |
100 |
} |
| |
26 |
101 |
} { |
| |
27 |
102 |
Synchronize the content repository with the file system. |
| |
28 |
103 |
This creates entries in sp_folders and static_pages, so the static_page |
| |
29 |
104 |
functions must be used to delete entries. |
| |
30 |
105 |
|