Finder error when moving and pasting a "virtual file"

72 views
Skip to first unread message

nirla...@gmail.com

unread,
Dec 18, 2014, 9:09:25 AM12/18/14
to osxfus...@googlegroups.com
Hello,
I am using the OS X fuse with a combination of the 2 provided samples:
HelloFS
LoopbackFS

My project combining both local files and virtual files (a simple NSArray with strings which represents filenames).

in:

- (NSArray *)contentsOfDirectoryAtPath:(NSString *)path error:(NSError **)error

I return the content of my strings array and a content of a random local folder using contentsOfDirectoryAtPath.

in:

- (NSDictionary *)attributesOfItemAtPath:(NSString *)path userData:(id)userData error:(NSError **)error

and in:

- (NSDictionary *)attributesOfFileSystemForPath:(NSString *)path error:(NSError **)error

i return 2 styles of attributes:

1. for the local items i return the items attributes using NSFileManager:

 NSDictionary* attribs = [[NSFileManager defaultManager] attributesOfItemAtPath:p error:error];

2. for the virtual files (those from the array), I return a dummy temp attributes like this:

   

NSDate *creationDate = [NSDate date];
NSDate *modificationDate = [NSDate date];
NSDictionary *attributes = @{    NSFileCreationDate : creationDate,
                                 
NSFileModificationDate : modificationDate,
                                 
NSFileExtensionHidden : @(0),
                                 
NSFileGroupOwnerAccountID : @(20),
                                 
NSFileGroupOwnerAccountName : @"myFile",
                                 
NSFileHFSCreatorCode : @(0),
                                 
NSFileHFSTypeCode : @(0),
                                 
NSFileOwnerAccountID : @(501),
                                 
NSFilePosixPermissions : @(420),
                                 
NSFileReferenceCount : @(1),
                                 
NSFileSize : @(5445555),
                                 
NSFileSystemFileNumber : @(107406206),
                                 
NSFileSystemNumber : @(16777217),
                                 
NSFileType : NSFileTypeRegular
                                 
};


The issue is as follow:

When I am dragging or pasting a local file ( a file which really exist) to a any other folder, the file is being moved/copied successfully and without any errors.

When I do the same for a virtual file, the file immediately appears in the destination folder, but I get an the following error:

A newer item named “banana.png” already exists in this location. Do you want to replace it with the older one you’re moving?

in the example, banana.png is an item from the NSArray I am using - Attached screenshot with the error.
BTW, when i drag/paste the item, non of the delegate methods, except the attributes ones, are being called.

What am I doing wrong? what am i missing?

Thank you!
 

Screen Shot 2014-12-18 at 3.37.25 PM.png

Sam Moffatt

unread,
Dec 18, 2014, 11:44:25 PM12/18/14
to osxfus...@googlegroups.com
Are you sure you're not returning that the virtual file you're copying in exists when you get a request for the attributesOfItemAtPath in the new location? My usual debugging suggestion is to run your file system with debug mode on and in single threaded mode to see if you can repro the issue in case there is some sort of race condition in your code. Finder can be very picky and if you don't feed it exactly the right answers to it's questions, it can respond in very strange looking ways.

Cheers,

Sam

--
You received this message because you are subscribed to the Google Groups "OSXFUSE" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osxfuse-grou...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

nirla...@gmail.com

unread,
Dec 21, 2014, 12:29:19 AM12/21/14
to osxfus...@googlegroups.com
Hi Sam,
So I understand they is to handle the attributes dictionary i return in attributesOfItemAtPath for the new path, but should i return nil for the new path?
In addition, what any other indication i have that this virtual file has been moved to another dictionary?
None of the other delegates is being called, only attributesOfItemAtPath.

Thank you!

Sam Moffatt

unread,
Dec 22, 2014, 12:15:06 AM12/22/14
to osxfus...@googlegroups.com
Until the file is created you shouldn't return a result to attributesOfItemAtPath because it shouldn't exist yet at that path. Your implementation always mutates the dates so when Finder asks to see if the file exists, it always sees a newer modification date and presents the dialog you see. Once you get the moveItemAtPath call, you can add it to the new location and remove it from the old one. There might be some slightly different calls (can't remember off the top of my head) but moveItemAtPath should be the delegate being called. Alternatively you might see calls to create an item and have the data copied across which would be harder to detect. 

Cheers,

Sam

--
Sam Moffatt
Note: I'm not at my desk, responses may be delayed

nirla...@gmail.com

unread,
Dec 22, 2014, 2:05:26 AM12/22/14
to osxfus...@googlegroups.com
Great response!
Thank you for this - its working now!
Reply all
Reply to author
Forward
0 new messages