rejetto forum

Bug in upload folder in file content, that writed by macros

XCanG · 15 · 8846

0 Members and 1 Guest are viewing this topic.

Offline XCanG

  • Occasional poster
  • *
    • Posts: 32
  • .do impossible  beat unbeatable
    • View Profile
    • Driver
Hello! I write some page, that iteract with hidden (real) folder on my server. This folder have 3 subfolders with macros actions, this macros save info into file.
One subfolder called set write GET variable ?t=value into "../time.json", second is unset, just set time to -1 (clear-like).
Another folder is posturl, it not compleated, but it add url that it get in POST request "url=" and write into watch.json new url + url it already content, also not implemented: deleting url by POST request, but I not finish this part of macros now.
Code is:
set
Code: [Select]
{.save|../time.json|{.urlvar|t.}.}unset
Code: [Select]
{.save|../time.json|-1.}posturl
Code: [Select]
{.set|url|{.postvar|url.}.}{.load|/sync/watch.json|var=w.}{.if|{.>|{.length|{.^w.}.}|1.}|{:{.if|{.>|{.length|{.^url.}.}|1.}|{:Server: Added to playlist{.set|playlist|{.^w.}{.^url.}.}{.save|../watch.json|var=playlist.}:}|{:Server: Remove currently playing video{.save|../watch.json|/.}:}.}:}|{:{.if|{.>|{.length|{.^url.}.}|1.}|{:Server: Create new playlist with requested entrie{.save|../watch.json|{.^url.}.}:}|{:Server: Nothing to remove, playlist is clear:}.}:}.}
Server: Current playlist entrie(s): {.^w.}{.^url.}

So, this work clearly some time ago, BUT it bugged.
In my real files writed on hard disk I have some values but if I download it directly from server now it return older value! and it not changed. I try to remove this folder from template and add again, BUT it still send older value, that different in real file content.

As I make iteactable page I also make some mistakes, that produce ton of request. And it return at that time to my browser 200 OK or 304 Unchanged. Now I fixed it, but I don't know why it bugged in HFS, HFS now remove some older value (in time.json and watch.json) on that it freezed.

P.S. this thing happen 2 days ago. And I, of course, restarting PC, HFS, folder readd in template.
P.S.S. HFS 2.3i Build 297
« Last Edit: July 02, 2016, 07:14:31 AM by XCanG »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
hi!
i understand your problem is that sometimes you get OLD content for those files. Right?
I suspect that may be because the current cache markers (Last-Modified in the HTTP) don't tell changes if they happen within a second.
Do you think that could be the case?
In case, I can surely fix this.

Otherwise, can you please give me a clear step-by-step way to reproduce the problem?
« Last Edit: July 04, 2016, 08:06:11 AM by rejetto »


Offline XCanG

  • Occasional poster
  • *
    • Posts: 32
  • .do impossible  beat unbeatable
    • View Profile
    • Driver
Ok, step by step:
1) in HDD create sync folder and add as real folder at HFS root with hidden parameter (site.com/sync/)
2) add at HDD set, unset, posturl folder
3) create in folders hfs.diff.tpl with content I post above
4) create new .html file and add it in HFS (don't matter where it will be, may be not on this server)
5) edit html-file, this file have property requests on JS. GET to set / unset / watch.json / time.json
Example:
Code: [Select]
var timevalue = ...;
let xhr = new XMLHttpRequest();
xhr.open("GET", "/sync/set/?t=" + timevalue, true);
xhr.send();
xhr.onreadystatechange = function() {
if (this.readyState != 4) return;
if (this.status == 200 || this.status == 304) {
console.log("async ended");
}
}
POST for posturl
Example:
Code: [Select]
function addurl(url) {
url = encodeURI(url);
let data = {
url: url // will be more complex later
};
let boundary = String(Math.random()).slice(2);
let boundaryMiddle = '--' + boundary + '\r\n';
let boundaryLast = '--' + boundary + '--\r\n';
let body = ['\r\n'];
for (let key in data) {
body.push('Content-Disposition: form-data; name="' + key + '"\r\n\r\n' + data[key] + '\r\n\r\n'); // add extra newline at end
}
body = body.join(boundaryMiddle) + boundaryLast;
let xhr = new XMLHttpRequest();
xhr.open('POST', '/sync/posturl/', true);
xhr.setRequestHeader('Content-Type', 'multipart/form-data; boundary=' + boundary);
xhr.onreadystatechange = function() {
if (this.readyState != 4) return;
if (this.status == 200 || this.status == 304) {
console.log("addurl(): %s", this.responseText);
// ...
}
}
xhr.send(body);
}
6) open page and call functions (some of it semiautomatically, like time checked every 4 second (P.S. want to set update at 1 second, but after calculations found some bug that it not ideal correctly and have delay about 300ms))


Offline XCanG

  • Occasional poster
  • *
    • Posts: 32
  • .do impossible  beat unbeatable
    • View Profile
    • Driver
So, 3 days of testing work fine, but at 4th day after my mistake in JS logic it bugged (I request too many GET/POST on the same files)

If you want to reproduce it you may just call code or function inside setInterval(code/function, delay_in_ms);

P.S. Also my file list bugged again. Private folder for users of specific group. Why it bugged again if I don't touch it after it setuped and work? Cause now only 3 solutions: give file to you again, create new file list or still do nothing with folder cause it crash HFS. // Look at old thread: http://www.rejetto.com/forum/bug-reports/bug-with-folder-(hfs-2-3-282)/ here is same problem again. Now I just want add one new group to permission for this folder, but can't.
« Last Edit: July 06, 2016, 02:03:20 PM by XCanG »


Offline XCanG

  • Occasional poster
  • *
    • Posts: 32
  • .do impossible  beat unbeatable
    • View Profile
    • Driver

Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
i followed all steps 1-5, but it's not clear to me what i have to for step 6. I tried calling addurl with few values.
You should be clear about what to do, give me the instructions that make the calls to the functions you want.
Also tell me what is the supposedly correct result, and what is the wrong result that you get.

Anyway, i already started fixing a problem that can cause HFS to give old files in case of cache.

I understand your problem is that you get an old watch.json, right?
In case, I have a suggestion: try to "disable" the cache. You can do this by appending some extra code to the URL of watch.json, like "watch.json?"+Math.random()
See if that helps.

Why you use plain XHR when you could use jquery to help you with that?


Offline XCanG

  • Occasional poster
  • *
    • Posts: 32
  • .do impossible  beat unbeatable
    • View Profile
    • Driver
1) Hm, may be I may give you html file, that call it and .vfs file to test it 1 in 1. I also recieve you mail, may send it to mail. EDIT reply to mail, check it.
2) watch.json and time.json, both files bugged.
3) Ok, will try random and add results later. EDIT Ugh, I don't know how long, but bug is fixed (I do nothing than wait). When I post at July 12 it still bugged, but now (July 22) it unbugged and I don't know will help random to fix it or not. May be if I can call bug again.
4) I don't add any libraries and do page simple as possible.
« Last Edit: July 22, 2016, 08:42:11 AM by XCanG »


Offline bmartino1

  • Tireless poster
  • ****
    • Posts: 910
  • I'm only trying to help i mean no offense.
    • View Profile
    • My HFS Google Drive Shared Link
since we are dealing with a time clock incident, i would have you check the PC time server, it could be and issue with the machine and its own time, especial since some time areas change for "daylights saving time"

i recommend using the linux universal time ntp server: pool.ntp.org

Files I have snagged and share can be found on my google drive:

https://drive.google.com/drive/folders/1qb4INX2pzsjmMT06YEIQk9Nv5jMu33tC?usp=sharing


Offline XCanG

  • Occasional poster
  • *
    • Posts: 32
  • .do impossible  beat unbeatable
    • View Profile
    • Driver
bmartino1, currently I tested all on local machine, so it only local time. I don't think that problem appear there, as it appear some next days later after PC rebooting many times (at least to July 12).


Offline LeoNeeson

  • Tireless poster
  • ****
    • Posts: 842
  • Status: On hiatus (sporadically here)
    • View Profile
    • twitter.com/LeoNeeson
@XCanG: It would be better if you ZIP all your HFS folder and upload it here, so we can analyse your current configuration. You don't need to share your current VFS file or any of your private files, only make a different separate folder, and configure everything exactly the same way as you have in your current HFS folder. Recreate all the settings you have in your actual HFS folder, and then share it here, please. ;)
HFS in Spanish (HFS en Español) / How to compile HFS (Tutorial)
» Currently taking a break, until HFS v2.4 get his stable version.


Offline XCanG

  • Occasional poster
  • *
    • Posts: 32
  • .do impossible  beat unbeatable
    • View Profile
    • Driver
@XCanG: It would be better if you ZIP all your HFS folder and upload it here, so we can analyse your current configuration. You don't need to share your current VFS file or any of your private files, only make a different separate folder, and configure everything exactly the same way as you have in your current HFS folder. Recreate all the settings you have in your actual HFS folder, and then share it here, please. ;)
I already send all what need to rejetto mail, if they think about share — ok, but currenly I don't like this idea, because some code I make will public. Scripts I already shered here, .vfs just struct html file and sync folder, what's it.


Offline LeoNeeson

  • Tireless poster
  • ****
    • Posts: 842
  • Status: On hiatus (sporadically here)
    • View Profile
    • twitter.com/LeoNeeson
:) OK, no problem, there is no need to share it here, if you sent it to Rejetto, that's enough, since he will find the problem. Anyway, never upload a private configuration, containing passwords or usernames. That's why I've said to "recreate" your current configuration, and NOT to share your current private configuration (sorry if my english is not good).



Translated using Google - Переведено с помощью Google

ОК, нет проблем, нет необходимости делить его здесь, если вы послали его к Rejetto, этого достаточно, так как он найдет эту проблему. Во всяком случае, никогда не загружать собственной конфигурации, содержащие пароли или имена пользователей. Вот почему я сказал "воссоздать" текущую конфигурацию, а не разделять вашу текущую конфигурацию собственной (извините, если мой английский не является хорошим).
HFS in Spanish (HFS en Español) / How to compile HFS (Tutorial)
» Currently taking a break, until HFS v2.4 get his stable version.


Offline XCanG

  • Occasional poster
  • *
    • Posts: 32
  • .do impossible  beat unbeatable
    • View Profile
    • Driver
OK, but no need translation. Better is see right english, than bad russian, because bad translating crush meaning.

So in my situation useful is only /sync/ folder with 3 scripts. External html file may be on different server, so, don't matter what code it will content, it just use tis 3 scripts and read many times saved files. Most frequency is time.json. All commands double check it. And only some commands read watch.json. It read only if command not accept time value (-1 (not set) or time in file later than current time (error) or time is obsolete (normal situation, when time need to update)).


Offline LeoNeeson

  • Tireless poster
  • ****
    • Posts: 842
  • Status: On hiatus (sporadically here)
    • View Profile
    • twitter.com/LeoNeeson
OK, but no need translation. Better is see right english, than bad russian, because bad translating crush meaning.
Yes, it's true, Google is not very good translating. I only was trying to help, but in your case, it's better to wait Rejetto's reply, since he is the only who can help you.
HFS in Spanish (HFS en Español) / How to compile HFS (Tutorial)
» Currently taking a break, until HFS v2.4 get his stable version.


Offline Fysack

  • Tireless poster
  • ****
    • Posts: 598
  • present picture
    • View Profile
    • Admin
Yes, it's true, Google is not very good translating. I only was trying to help, but in your case, it's better to wait Rejetto's reply, since he is the only who can help you.
;D ;D ;D
GOD CAN READ YOUR MIND