Closed Bug 236920 Opened 20 years ago Closed 20 years ago

It's impossible to find out if an "Flush" for an RDF-File was successful

Categories

(Core Graveyard :: RDF, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: Manuel.Spam, Assigned: axel)

References

Details

Attachments

(1 file, 1 obsolete file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; de-AT; rv:1.7a) Gecko/20040219
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; de-AT; rv:1.7a) Gecko/20040219

It seems to be impossible to find out if the "flush" of an RDF-Database was
successful. If the disc where the RDF has to be saved to is full then there is
no way to find out that the data couldn't be written.

I've asked in #mozilla for that. A short IRC-Log is following:

	MReimer	I'm trying to use RDF for saving data in an extension. To save my file
I call "GetDataSource" first to open tha (empty) file. Then I save my data with
RDF-functions. When ready with saving I get an"nsIRDFRemoteDataSource" for it
and I call "flush". This works great but
	MReimer	if the disc where I save to is full simply nothing is saved. I don't
get an error and so I don't know how much is saved. Is there a way to find out
if the "flush" was successful?
	timeless	that's odd, or terrifying
	|<--	adamhauner hat moznet verlassen (Quit: ChatZilla 0.9.60 [Mozilla/5.0
(Windows; U; Windows NT 5.0; en-US; rv:) Gecko/20040307])
	biesi_	botbot, trees
	timeless	tor: btw, thanks for tolerating the silly gui requests
	botbot	SeaMonkey <open>: all 8 tinderboxen green!
	botbot	Phoenix <open>: all 3 tinderboxen green!
	biesi_	timeless, you are surprised (re rdf failing silently)?
	timeless	biesi: hrm
	timeless	ponders
	timeless	oh right, bookmarks has its own impl of flush
	timeless	mreimer: do you have to know which class of datasource you have?
	timeless	ewww
	timeless	kicks something
	timeless
http://lxr.mozilla.org/seamonkey/source/rdf/base/src/nsRDFXMLDataSource.cpp
	timeless	812 nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(aURI);
	timeless	814 if (fileURL) {
	timeless	815 nsCOMPtr<nsIFile> file;
	timeless	816 fileURL->GetFile(getter_AddRefs(file));
	timeless	817 if (file) {
	timeless	...
	timeless	830 }
	timeless	831 }
	timeless	832
	timeless	833 return NS_OK;
	biesi_	typical
	timeless	so, if !fileURL or !file, it returns ok
	timeless	then there's
	timeless	1152 RDFXMLDataSourceImpl::Serialize(nsIOutputStream* aStream)
	timeless	which relies on some xpcom which i've seen broken on occasion
	glazou	Hixie: no, CSS 2 is ***not*** obsolete at all
	-->|	mvl (~michiel@lions.xs4all.nl) hat #mozilla betreten
	glazou	CSS 2 still stands, and it's still possible to implement CSS 2 features
that are NOT in CSS 2.1
	glazou	saying that CSS 2 is obsolete is a major error
	doron	css gladiators!
	timeless	ok
	timeless	the real problem is /probably/ all calls to rdf_BlockingWrite
	glazou	for the moment, I am fighting with our sucking implem of -moz-user-*
	timeless	doesn't think *anyone* is checking the rv
	MReimer	timeless:Sorry, but I'm new with mozilla programming. I have an
nsIRDFService where I call my GetDataSource for an empty or not existing file.
Then I use this datasource for setting my data. when ready I call the "flush". I
don't know very much about "classes of datasources"
	timeless	MReimer: find/file a bug, cc timeless@b, copy all of my relevant
ramblings from the past few minutes
	bsmedberg	MReimer: cc bsmedberg@,axel@pike,tingley@ also, please

Reproducible: Always
Steps to Reproduce:
Save (flush) an RDF-File to an Disc (Floppy) which is nearly full.

Actual Results:  
The RDF-File doesn't get created since the disc is full. There is no way to find
out that the writing failed

Expected Results:  
It should be possible to find out when the write failed.
The calls in 
http://lxr.mozilla.org/seamonkey/source/rdf/base/src/nsRDFXMLSerializer.cpp
to rdf_BlockingWrite must check the rv.
Status: UNCONFIRMED → NEW
Ever confirmed: true
So, the first bits were already done on boffo a while ago...
Attached patch first draft (cost: 25k) (obsolete) — Splinter Review
Comment on attachment 143498 [details] [diff] [review]
first draft (cost: 25k)

comments? should i really keep the current approach of making 5 calls to
rdf_BlockingWrite in a row?
Attachment #143498 - Flags: review?(axel)
Comment on attachment 143498 [details] [diff] [review]
first draft (cost: 25k)

erm, 25k, but who's counting.
Attachment #143498 - Attachment description: first draft (cost: 250k) → first draft (cost: 25k)
Comment on attachment 143498 [details] [diff] [review]
first draft (cost: 25k)

rdf_BlockingWrite(nsIOutputStream* stream, const char* buf, PRUint32 size)
does not do a UTF16toUTF8 conversion, so that should be used whenever possible.
The number of calls into rdf_BlockingWrite seems less important to me as we're
using a buffered output stream anyway, but if you care, convert to UTF8
outside, concat and then call into the utf8 version.
rdf_BlockingWrite(aStream, NS_LITERAL_STRING("\n		   "));
should really be
rdf_BlockingWrite(aStream, "\n			 ", 20);
(if I counted right ;-))
Attachment #143498 - Flags: review?(axel) → review-
Depends on: 239369
taking.
Assignee: rjc → axel
OS: Windows 2000 → All
Hardware: PC → All
Comment on attachment 143498 [details] [diff] [review]
first draft (cost: 25k)

bug 239369 has a patch
Attachment #143498 - Attachment is obsolete: true
fixed with bug 239369.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: