Closed StianOby closed 9 years ago
This error has popped up from time to time and I was never able to resolve it because I couldn't reproduce it. You hint about linux and windows machine might explain it though so that I might be able to fix it.
I there a line number in the error message? Can you send the content of the note for an attachment item that you sent from your windows machine? It should look like this:
lastmod{1357554440000}; mode{1}; location{[BaseFolder]/Projects/Knight_2012_Education.pdf}; projectFolder{/Projects/education}
These are the full details of the error message (copied by clicking the "ZotFile error" box popping up in the bottom-right corner):
"Error: TypeError: f.exists is not a function"
The content of the attachment item note for the item in question is:
lastmod{1385488405000}; mode{1}; location{[BaseFolder]/Patterson_2013_A_Companion_to_Philosophy_of_Law_and_Legal_Theory.pdf}; projectFolder{}
I was successfully able to "Get" this item with Zotfile with my home (windows) computer. So, this seems to be some kind of compatability issue.
Ok, I just committed a change that might fix the problem. But I can't really test it because I don't have a windows machine. Can you try the current development version on github? It would be good if you could test the following scenarios: 1) send on windows, get on windows 2) send on windows, get on mac/unix 3) send on mac/unix, get on windows 4) send on mac/unix, get on mac/unix But it's important that you change the file on dropbox between sending and getting it back. So you can just annotate it as usually or go to your tablet folder (dropbox in my case) and add some random annotation.
If this doesn't work, it would be good to know in which of the four scenarios the problem occurs (either in the old or new version)
Thanks!
OK, I will try to test it over the next couple of days. On Dec 9, 2013 11:09 PM, "jlegewie" notifications@github.com wrote:
Ok, I just committed a change that might fix the problem. But I can't really test it because I don't have a windows machine. Can you try the current development version on github? It would be good if you could test the following scenarios: 1) send on windows, get on windows 2) send on windows, get on mac/unix 3) send on mac/unix, get on windows 4) send on mac/unix, get on mac/unix But it's important that you change the file on dropbox between sending and getting it back. So you can just annotate it as usually or go to your tablet folder (dropbox in my case) and add some random annotation.
If this doesn't work, it would be good to know in which of the four scenarios the problem occurs (either in the old or new version)
Thanks!
— Reply to this email directly or view it on GitHubhttps://github.com/jlegewie/zotfile/issues/126#issuecomment-30178927 .
I am not sure but it might be the that I forgot to sync my changes yesterday to github. Now everything should be updated for sure.
I have now tested scenario (1) and (4), which both work.
Scenario (2) I have also tested, but with mixed results. I did not get the afromentioned error, and Zotfile seemed to report the "Get" action as a success. However, when inspecting the PDF, I found that the edit I did when the file was on Dropbox was not there. And the file that was "Sent" to Dropbox was not removed/deleted when "Get"ing it back. In other words, it seems like Zotfile left it on Dropbox, and didn't overwrite the copy in Zotero. Even though the error seems to be gone, we might thus only have uncovered a deeper problem...
okay, thanks. I will try to look into it later this week. Can you send me the content of one of the notes when you send the file on windows?
One example (Sent to tablet/Dropbox on windows):
; lastmod{1386058797000}; mode{1}; location{[BaseFolder]\Patterson_2013_A_Companion_to_Philosophy_of_Law_and_Legal_Theory.pdf}; projectFolder{}
Sorry for the delay. I am not able to reproduce this. Just uploaded a new version to github, which adds a small info window showing the location for each 'get' operation (there also is an window for sending a file but it reports nonsense). The window shows the file path on the tablet and a true or false indicating whether the file exists. Clicking on the window copies the path to the clipboard. Can you recheck with this version and report more details about the problem? Thanks!
Will try to get back to you over new year's. Thanks got following up! On Dec 27, 2013 12:11 AM, "jlegewie" notifications@github.com wrote:
Sorry for the delay. I am not able to reproduce this. Just uploaded a new version to github, which adds a small info window showing the location for each 'get' operation (there also is an window for sending a file but it reports nonsense). The window shows the file path on the tablet and a true or false indicating whether the file exists. Clicking on the window copies the path to the clipboard. Can you recheck with this version and report more details about the problem? Thanks!
— Reply to this email directly or view it on GitHubhttps://github.com/jlegewie/zotfile/issues/126#issuecomment-31239756 .
Is this new version you mentioned in your last comment now pushed to the extension directory, or will I still have to download from Git?
No, I actually rolled back the changes because I wasn't able to reproduce the bug and wanted to put out a beta without including untested changes. But I am happy to at them again if you have some time to test it now?
I will probably have time next week. Sorry for coming back to you this late, but I forgot about it all through this rather hectic january.
I currently have a beta out with a number of changes, which I would like to test first. You could install the beta from here and just use it normally. I will post here again when that is done so that we can get back to the other issue.
Just updated Zotfile to version 3.2 (the one in the archive at addons.mozilla.org/zotfile), and I still get:
"Error: TypeError: f.exists is not a function"
When fetching an item that I have on my tablet. (Which was sent to the tablet with version 3.1, if that could have had any effect).
This might help debugging further: After upgrading to 4.1 i attempted to "get" an attachment again facing the "TypeError: file.exists is not a function" error. I then attempted to click "update file modification time", just for the heck of it, and got a more precise error message:
"TypeError: file.exists is not a function(chrome://zotfile/content/zotfile.js, 2393)"
Maybe this will put you on the right track?
Thanks. Are you using Firefox or standalone? If you can use FF with your Zotero library, could you try running some code? Here is how you get started:
Display
(you can also use Inspect
with the file
variablevar zz = Zotero.ZotFile,
att = ZoteroPane.getSelectedItems()[0];
this.getInfo(att,"location");
var file = zz.createFile(zz.getInfo(att,"location"));
typeof(file)
'exists' in file
Will try monday when I am back at the office. (I'm running the Zotero Firefox extension).
Great, thanks. The problem might have something to do with changing from windows to unix/mac systems...
I get the following after pasting the code into scratchpad and clicking the "Display" button:
"/ Exception: this.getInfo is not a function @Scratchpad/1:12:1 WCA_evalWithDebugger@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/devtools/server/actors/webconsole.js:1106:16 WCA_onEvaluateJS@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/devtools/server/actors/webconsole.js:730:20 DSC_onPacket@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/devtools/server/main.js:1223:15 LocalDebuggerTransport.prototype.send/<@resource://gre/modules/devtools/dbg-client.jsm -> resource://gre/modules/devtools/transport/transport.js:545:11 makeInfallible/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/devtools/DevToolsUtils.js:83:14 makeInfallible/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/devtools/DevToolsUtils.js:83:14 /"
uuups, the code was supposed to be
var zz = Zotero.ZotFile,
att = ZoteroPane.getSelectedItems()[0];
zz.getInfo(att,"location");
var file = zz.createFile(zz.getInfo(att,"location"));
typeof(file)
'exists' in file
Tried the updated code, but now I face a new exception: "/ Exception: invalid 'in' operand file @Scratchpad/2:16:1 WCA_evalWithDebugger@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/devtools/server/actors/webconsole.js:1106:16 WCA_onEvaluateJS@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/devtools/server/actors/webconsole.js:730:20 DSC_onPacket@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/devtools/server/main.js:1223:15 LocalDebuggerTransport.prototype.send/<@resource://gre/modules/devtools/dbg-client.jsm -> resource://gre/modules/devtools/transport/transport.js:545:11 makeInfallible/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/devtools/DevToolsUtils.js:83:14 makeInfallible/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/devtools/DevToolsUtils.js:83:14 /"
That makes sense. What is the output from zz.getInfo(att,"location")
and typeof(file)
? One should a location on your system. Does that file exists when you look yourself?
var zz = Zotero.ZotFile, att = ZoteroPane.getSelectedItems()[0];
zz.getInfo(att,"location"); / C:\Users\stiaoj\Dropbox\ZotFile/Juuhl-Langseth_2014_EU-domstolen.pdf /
And here is the path to the file as it appears on my Windows computer at work: "C:\Users\stiaoj\Dropbox\ZotFile\Juuhl-Langseth_2014_EU-domstolen.pdf"
I guess the forward slash may be the issue?
Yes, it is. I assume C:\Users\stiaoj\Dropbox\ZotFile
is your base folder, right? The forward slash is there because you send the file from a mac/unix system, right?
That is the base folder, yes. The forward slash is probably a result of me sending the file from an Linux/Ubuntu (unix) system - although I am not 100% certain for that exact article.
Okay, can you try running this in Scratchpad (Zotero tab still needs to be open). It replaces the relevant function in Zotfile. Afterwards you can try to get the file from the tablet as usual (right click->manage attachments-> get from tablet). I will commit the patch when it works.
Zotero.ZotFile.getInfo = function (att, key) {
var win = this.wm.getMostRecentWindow("navigator:browser"),
note = win.document.createElementNS(this.xhtml, 'div'),
content = att.getNote(),
value;
try {
try {
note.appendChild(this.parseHTML(content));
}
catch(e) {
var match = content.match(/<p id="zotfile-data".+<\/p>/);
if (match===null)
match = content.match(/lastmod{.+}/);
if (match===null)
return '';
note.appendChild(this.parseHTML(match[0]));
}
// get zotfile data
var p = note.querySelector("#zotfile-data");
if(p===null) {
// support for old system
var search = content.search(key);
value = content.substring(search);
value = value.substring(value.search("{")+1,value.search("}"));
}
else {
var data = JSON.parse(p.getAttribute('title'));
value = data[key]===undefined ? '' : data[key];
}
// for location tag: replace [BaseFolder] with destination folder
if(key=="location") value = value.replace("[BaseFolder]",this.prefs.getCharPref("tablet.dest_dir"));
// for location tag: correct window/mac file system
if(key=="location" && Zotero.isWin) value = value.replace('/', '\\');
if(key=="location" && (Zotero.isMac || Zotero.isLinux)) value = value.replace('\\', '/');
// return
return(value);
}
catch (err) {
return '';
}
};
It works! Thank you so much for your patience and effort :-)
Okay, great. Thanks for helping out. I just committed the patch. If you install the current version from github everything should work (not the one under releases though). Let me know if any problems emerge with this version. Note that running the code in Scratchpad only fixes the problem until you restart FF. So you have to install the version from github to really fix it.
When trying to "Get" an item from my tablet (Dropbox folder) i get the following error message: "TypeError: f.exists is not a function"
From searching here i found this previous issue (#102): https://github.com/jlegewie/zotfile/issues/102
I guess my problem might be related. If I remember correctly, the item I am trying to "Get" with my Windows machine at work was "Sent" from my Linux machine at home.