Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.radio.upstream.uploadRecentlyTouchedFiles
<<Changes
<<12/11/01; 12:50:01 PM by DW
<<Wired off. Does nothing.
<<12/6/01; 7:48:17 PM by DW
<<The callback-calling code was broken, so the callbacks were never getting called, and this broke Weblogs.Com notification. It was passing a list containing a single list of N files, instead of a list of N files. Easy fix, once found. ;->
<<12/6/01; 2:05:29 PM by DW
<<Change logging message to be consistent with radio.upstream.uploadchangedfiles.
<<12/4/01; 2:48:38 PM by JES
<<Maintain adfile^.upstream.flError flag.
<<11/27/01; 9:49:12 PM by JES
<<Improved the About window messages.
<<11/27/01; 6:20:42 PM by JES
<<Respect offline status. Call the callbacks once with a list of files, instead of once for each file with a list containing the path to a single file.
<<11/27/01; 6:03:18 PM by JES
<<Respect user.radio.prefs.upstream.enabled.
<<11/27/01; 9:35:28 AM by DW
<<Created. Loop over the files in system.temp.radio.recentlyWrittenWwwFiles.
<<We're interested in files that are going out via xmlStorageSystem, files that are in the upstream domain of the top level of the www folder. The goal is to optimize the most likely case. If you're going to another upstream folder, or going out through another driver, it'll work, but it will be slower. Other optimizations are possible by further developing this routine.
return; //12/11/01; 12:49:58 PM by DW
if user.radio.prefs.upstream.enabled {
if not tcp.isOffline () {
local (startticks = clock.ticks ());
local (adrtable = @system.temp.radio.recentlyWrittenWwwFiles, adrrootspec);
bundle { //set adrrootspec
local (adrfile);
radio.file.getFileAttributes (user.radio.prefs.upstream.folder, @adrfile);
radio.upstream.getUpstreamSpec (adrfile, @adrrootspec);
if adrrootspec^.type != "xmlStorageSystem" {
table.emptytable (adrtable);
return}};
local (filelist = {}, adr);
for adr in adrtable {
local (f = nameof (adr^), adrfile, adrspec);
if file.exists (f) {
radio.file.getFileAttributes (f, @adrfile);
if radio.upstream.getUpstreamSpec (adrfile, @adrspec) {
if adrspec == adrrootspec {
filelist = filelist + {adrfile};
bundle { //set the relative path
local (s = string.delete (f, 1, sizeof (adrfile^.baseUpstreamFolder)));
s = string.replaceAll (s, file.getpathchar (), "/");
adrfile^.relativePath = s};
bundle { //set an item in system.temp.radio.recentlyChangedFolders to trigger rebuild of directory.opml
if string.lower (file.folderFromPath (f)) == string.lower (adrfile^.baseUpstreamFolder) {
if string.lower (file.filefrompath (f)) != string.lower (radio.data.upstream.directoryFileName) {
system.temp.radio.recentlyChangedFolders.[adrfile^.baseUpstreamFolder] = clock.now ()}}}}}}};
table.emptytable (adrtable);
if sizeof (filelist) > 0 {
on runCallbacks (filelist, adrcallbacktable) {
local (nomad);
try {
for nomad in adrcallbacktable {
while typeOf (nomad^) == addressType {
nomad = nomad^};
try {nomad^ (filelist)}}}}; //site of an outage -- 12/6/01; 7:49:55 PM by DW
with adrrootspec^ {
local (password = string (user.radio.prefs.passwords.[passwordName]), response);
local (relativepathlist = {}, filetextlist = {}, filepathlist = {});
bundle { //fill relativepathlist, filetextlist
local (adrfile);
for adrfile in filelist {
local (f = nameof (adrfile^));
local (relativePath = adrfile^.relativePath);
filetextlist = filetextlist + {radio.upstream.getUpstreamText (f, @relativePath)};
adrfile^.upstream.whenLastUploaded = clock.now (); //only try once
relativepathlist = relativepathlist + {relativePath};
filepathlist = filepathlist + {f}}};
msg ("Upstreaming " + sizeof (filetextlist) + " files to " + adrrootspec^.server + "...");
local (flerror, message, urllist);
try {
local (data = adrrootspec^); data.fldebug = false;
xmlStorageSystem.writeMultipleFiles (usernum, password, relativepathlist, filetextlist, @response, adrdata:@data, flShowMessages:false);
flerror = response.flerror;
message = response.message;
urllist = response.urllist}
else {
flerror = true;
message = tryerror;
urllist = {}};
<<scratchpad.response = response
bundle { //record info about the files
local (i, adrfile);
for i = 1 to sizeof (filelist) {
adrfile = filelist [i];
if flerror {
adrfile^.upstream.flError = true}
else { //no error, increment ctUploads, set url, set flError to false
adrfile^.upstream.ctUploads++;
adrfile^.upstream.url = urllist [i];
adrfile^.upstream.flError = false}}};
bundle { //run callbacks
if defined (radio.upstream.callbacks.upstream) {
runCallbacks (filepathlist, @radio.upstream.callbacks.upstream)};
if defined (user.radio.callbacks.upstream) {
runCallbacks (filepathlist, @user.radio.callbacks.upstream)}};
bundle { //logging
if user.radio.prefs.upstream.logging {
local (htmltext = "");
if flerror {
htmltext = "Error: " + message}
else {
local (url);
for url in urllist {
htmltext = htmltext + "<a href=\"" + url + "\">" + string.nthfield (url, "/", string.countfields (url, "/")) + "</a>, "};
htmltext = sizeof (urllist) + " files: " + string.delete (htmltext, sizeof (htmltext) - 1, 2) + "."};
radio.log.add ("Upstream", htmltext, startticks)}};
msg ("")}}}}
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.