Closed Bug 304630 Opened 19 years ago Closed 19 years ago

File.remove doesn't delete anything

Categories

(Core Graveyard :: Installer: XPInstall Engine, defect)

defect
Not set
major

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: Manuel.Spam, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; de-AT; rv:1.7.11) Gecko/20050728
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; de-AT; rv:1.7.11) Gecko/20050728

I've tried to use "File.delete" in my install.js to kill a file in the user's
profile. "File.delete" doesn't return any error, but it also doesn't delete the
file. Even "File.isWritable" wants to tell me that the file isn't writable. If I
just do an "rm" on shell with the same user running mozilla I can delete the
file... 

I've used the following test code in my install.js:

initInstall("test", "testinstall", "0.0.1"); 
profiledir = getFolder("Profile");

alert(profiledir);
if (File.exists(profiledir + "/testfile")) {
    alert("exists");
    alert(File.isWritable(profiledir + "/testfile"));
    File.remove(profiledir + "/testfile");
}

performInstall();
alert(getLastError());

Reproducible: Always

Steps to Reproduce:
1. Save the above code to a file called "install.js"
2. do an "zip test.xpi install.js" in the same directory
3. Create the file "testfile" in the profile path
4. Try to open to install the file.
5. You'll get the following messages:
   - The profile path
   - The message "exists"
   - A "false" from "isWritable"
   - A zero that tells us that there was no error during install
Actual Results:  
The file doesn't ge deleted

Expected Results:  
File.delete should delete the file
Sorry for the spam, but this is invalid...

Even if this is difficult to understand and difficult to find out for people
that never worked with XPInstall before the code I've posted has to look like this:

initInstall("test", "testinstall", "0.0.1"); 
profiledir = getFolder("Profile");
filetoremove = getFolder(profiledir, "testfile");

alert(profiledir);
if (File.exists(filetoremove)) {
    alert("exists");
    alert(File.isWritable(filetoremove));
    File.remove(filetoremove);
}

performInstall();
alert(getLastError());
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → INVALID
Summary: File.delete doesn't delete anything → File.remove doesn't delete anything
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.