daveappserver 0.5.27 → 0.5.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/appserver.js CHANGED
@@ -1,4 +1,4 @@
1
- var myVersion = "0.5.27", myProductName = "daveAppServer";
1
+ var myVersion = "0.5.31", myProductName = "daveAppServer";
2
2
 
3
3
  exports.start = startup;
4
4
  exports.notifySocketSubscribers = notifySocketSubscribers;
@@ -55,6 +55,8 @@ var stats = {
55
55
  };
56
56
  const fnameStats = "stats.json";
57
57
 
58
+
59
+
58
60
  function statsChanged () {
59
61
  flStatsChanged = true;
60
62
  }
@@ -534,13 +536,15 @@ function cleanFileStats (stats) { //4/19/21 by DW
534
536
  }
535
537
  function writethefile (flprivate) {
536
538
  var f = getFilePath (screenname, relpath, flprivate);
537
- fs.writeFile (f, filetext, function (err) {
538
- if (err) {
539
- callback (err);
540
- }
541
- else {
542
- callback (undefined);
543
- }
539
+ utils.sureFilePath (f, function () { //9/15/21 by DW
540
+ fs.writeFile (f, filetext, function (err) {
541
+ if (err) {
542
+ callback (err);
543
+ }
544
+ else {
545
+ callback (undefined);
546
+ }
547
+ });
544
548
  });
545
549
  }
546
550
  readone (false, function (err, data) {
@@ -553,6 +557,9 @@ function cleanFileStats (stats) { //4/19/21 by DW
553
557
  });
554
558
  });
555
559
  }
560
+ function getPublicUrl (screenname, relpath) { //8/24/21 by DW
561
+ return (config.urlServerForClient + screenname + "/" + relpath);
562
+ }
556
563
  function getFileInfo (screenname, relpath, callback) { //4/1/21 by DW
557
564
  if (config.flStorageEnabled) {
558
565
  findFile (screenname, relpath, function (err, stats) {
@@ -568,7 +575,8 @@ function cleanFileStats (stats) { //4/19/21 by DW
568
575
  whenAccessed: formatDate (stats.atime), //when last red
569
576
  whenCreated: formatDate (stats.birthtime),
570
577
  whenModified: formatDate (stats.mtime),
571
- flPrivate: stats.flPrivate
578
+ flPrivate: stats.flPrivate,
579
+ urlPublic: (stats.flPrivate) ? undefined : getPublicUrl (screenname, relpath) //8/24/21 by DW
572
580
  });
573
581
  }
574
582
  });
@@ -867,11 +875,24 @@ function startup (options, callback) {
867
875
  function returnPlainText (s) {
868
876
  theRequest.httpReturn (200, "text/plain", s.toString ());
869
877
  }
878
+
879
+ function getFileContent (screenname, relpath, flprivate, callback) { //9/8/21 by DW
880
+ var f = getFilePath (screenname, relpath, flprivate);
881
+ fs.readFile (f, function (err, filetext) {
882
+ if (err) {
883
+ callback (err);
884
+ }
885
+ else {
886
+ callback (undefined, filetext);
887
+ }
888
+ });
889
+ }
890
+
870
891
  var path = utils.stringDelete (theRequest.path, 1, 1); //delete leading slash
871
892
  var screenname = utils.stringNthField (path, "/", 1);
872
893
  var relpath = utils.stringDelete (path, 1, screenname.length + 1);
873
894
  var flprivate = false;
874
- getFile (screenname, relpath, flprivate, function (err, data) {
895
+ getFileContent (screenname, relpath, flprivate, function (err, filedata) {
875
896
  if (err) {
876
897
  return404 ();
877
898
  }
@@ -883,7 +904,7 @@ function startup (options, callback) {
883
904
  else {
884
905
  type = utils.httpExt2MIME (ext, config.defaultContentType);
885
906
  }
886
- theRequest.httpReturn (200, type, data.filedata);
907
+ theRequest.httpReturn (200, type, filedata);
887
908
  }
888
909
  });
889
910
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "daveappserver",
3
3
  "description": "Factored code that was appearing in all my servers.",
4
- "version": "0.5.27",
4
+ "version": "0.5.31",
5
5
  "main": "appserver.js",
6
6
  "repository": {
7
7
  "type" : "git",
package/readme.md CHANGED
@@ -50,3 +50,9 @@ The second section configures the HTTP server and the connection to Twitter for
50
50
 
51
51
  4. twitterConsumerKey and twitterConsumerSecret are the values that identify the app for Twitter, as assigned on developer.twitter.com.
52
52
 
53
+ ### Updates
54
+
55
+ v0.5.31 -- 9/15/21 by DW
56
+
57
+ writeWholeFile was meant to be sure the path to the file exists before writing the file. It wasn't doing it, now it does.
58
+
package/readme.opml CHANGED
@@ -44,5 +44,10 @@
44
44
  <outline text="4. twitterConsumerKey and twitterConsumerSecret are the values that identify the app for Twitter, as assigned on developer.twitter.com. "></outline>
45
45
  </outline>
46
46
  </outline>
47
+ <outline created="Wed, 15 Sep 2021 14:19:02 GMT" text="### Updates">
48
+ <outline created="Wed, 15 Sep 2021 14:19:10 GMT" text="v0.5.31 -- 9/15/21 by DW">
49
+ <outline created="Wed, 15 Sep 2021 14:19:12 GMT" text="writeWholeFile was meant to be sure the path to the file exists before writing the file. It wasn't doing it, now it does. "></outline>
50
+ </outline>
51
+ </outline>
47
52
  </body>
48
53
  </opml>