LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-12-2018, 06:58 AM   #1
rblampain
Senior Member
 
Registered: Aug 2004
Location: Western Australia
Distribution: Debian 11
Posts: 1,288

Rep: Reputation: 52
Firefox "save as" not working as expected.


I have a script that finds and reads and processes a "saved as" Firefox file then deletes it and wait for a new "saved as" file of the same name but although the old file has been effectively "deleted" (its name is not there anymore in "ls" before getting the new file), the script then processes the contents of the old file, not the contents of the new file and no matter of how many times this new file is changed. I suspect it is fetching the old original file contents of the same old file from a cache somewhere (since the name is not changed).
Could someone make suggestions (clear cache or use command more appropriate than "rm" or another browser)?

Using Firefox-esr 60.2.2

Thank you for your help.
 
Old 12-12-2018, 07:13 AM   #2
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
a man walks in to the doctors office, and says, hey Doc. I got a freind that every time he stands up, his pants falls down. What do you think is the matter with him?

Doc: Maybe he needs a new belt.
Friend: but he has no hips to keep the belt up.

gee I wish I had something to look at so I could tell what is really going on.
 
1 members found this post helpful.
Old 12-12-2018, 07:34 AM   #3
danielbmartin
Senior Member
 
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Mint 17.3
Posts: 1,881

Rep: Reputation: 660Reputation: 660Reputation: 660Reputation: 660Reputation: 660Reputation: 660
If you edit a file and want to save the revised version by replacing the original, you should use the SAVE button. The original file will be replaced by the revised version.

If you want to save the revised version with a different file name, you should use the SAVE AS button, and (when prompted) give the name for the new file. The original file will remain as it was.

Your post prompts the thought that you are using the wrong button and Firefox is operating correctly.

Daniel B. Martin

.
 
1 members found this post helpful.
Old 12-12-2018, 08:31 AM   #4
rblampain
Senior Member
 
Registered: Aug 2004
Location: Western Australia
Distribution: Debian 11
Posts: 1,288

Original Poster
Rep: Reputation: 52
Quote:
Your post prompts the thought that you are using the wrong button and Firefox is operating correctly.
The file is saved "as is" and then the "saved" file (its copy) is read by script and processed, not the original but Firefox does not offer a "save" option in this case, only a "save as" option. After processing, the "saved as" file (not the original) is removed (rm) and Firefox is closed. Finding the file is done by using "find newer.." than a dummy file just "touched" by the script for that purpose. After a certain time, the problem automatically disappears - for example waiting long enough between the processing of 2 different files by the same instance of the script which seems to support my view that a cache is involved.
 
Old 12-12-2018, 08:38 AM   #5
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
It would be easier to troubleshoot this if you posted your actual script, or the relevant section(s) thereof.
 
1 members found this post helpful.
Old 12-12-2018, 10:11 AM   #6
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
It's not enough to delete (unlink) the file, you have to close (close/fclose) it, then you can call open/fopen again.
 
2 members found this post helpful.
Old 12-12-2018, 12:31 PM   #7
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by NevemTeve View Post
It's not enough to delete (unlink) the file, you have to close (close/fclose) it, then you can call open/fopen again.
Yes. It's not what Firefox does, but what the script does with the file.
 
1 members found this post helpful.
Old 12-12-2018, 12:40 PM   #8
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Most likely unrelated, but once I had a mishap with glibc that did cause problems in firefox, see here:
https://bugzilla.mozilla.org/show_bu...=1042134#cs-26

(Firefox dlopened 'libc.so.6' and ended up with two libc.so.6 dynamically loaded... that had disturbing results.)
 
1 members found this post helpful.
Old 12-12-2018, 10:52 PM   #9
rblampain
Senior Member
 
Registered: Aug 2004
Location: Western Australia
Distribution: Debian 11
Posts: 1,288

Original Poster
Rep: Reputation: 52
Checked and files are properly open and closed at the appropriate time (just before and after reading/writing), I was expecting an obvious trick, not having much experience dealing with browser files, it is not the case. The script is over 900 lines of code, posting it will be too much for the volunteers to investigate and posting the relevant code will always leave the doubt there is something else of importance not showing. I am also limited with time and found the easy solution is to give the files a different name/extension (.001 etc) which works.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Python: how do you accomplish "chmod 2755 somedir" - os.chmod not working as expected BrianK Programming 2 11-29-2010 03:03 PM
C++ - "snprintf" inside "for" doesn't work as expected. (int to char*) Repgahroll Programming 14 08-31-2010 08:27 AM
X11 and Firefox not working as I expected ffc Linux - Newbie 2 10-02-2008 05:40 AM
Help With Java Problem Please"""""""""""" suemcholan Linux - Newbie 1 04-02-2008 06:02 PM
Firefox freezes at "Save", "Download" kjmorris Linux - Software 4 10-27-2004 02:44 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration