Trash files inside user-selected folder inside iCloud Drive - file

My app works with user txt-files (create, change, delete) inside any user-selected folder. I just internally store the bookmark to get access to that user-selected folder and files.
Now, with macOS Catalina when the source folder is inside iCloud Drive, system still allows me to create and edit files. But doesn't allow to trash one. When I try to do it via [[NSFileManager defaultManager] trashItemAtURL: ... ] I get the following error:
Error Domain=NSCocoaErrorDomain
Code=3328
"<filename> couldn’t be moved to the trash
because the volume “<APFS volume name>”
doesn’t have one."
UserInfo={
NSURL=file:///... <filepath>.txt,
NSUserStringVariant=Trash
}
Note: this only happens when the app is sandboxed.
Any ideas how to get the file trashed correctly?
P.S. I know there is a NSWorkspace recycle... method, but it makes an extra deletion prompt that is not suitable for me.
P.P.S. I am still able to use [[NSFileManager defaultManager] removeItemAtURL: ...] method, but I need the target file to be restorable in case user changes his mind.

Ok. Looks like it's a rare case. But if you've got into the same situation, here is what I've ended up with:
There is a deprecated function - FSMoveObjectToTrashSync - that still works just fine. It saved my ass for now.

Related

Where do i put mdl files for function SetModel

I am new in lua and gmod coding. I have already coded successfully a HUD's addons but i am stuck in another.
I want to create a new entity, and after reading lots of tutorial, i manage to do it but in game, the word ERROR appears in red when spawning, not the model. The server and the client are located on the same PC, for debugging considerations. I try to put mdl files on several folders without aby change.
I put mdl file in
addons/models/model.mdl
I think the client doesn't find the model file : do i need a workshop content even for testing ? Where do i put the files ?
Thanks.
I got it. When reusing existing MDL file, i must keep the original path for files.
That is, when opening mdl file, a path is writing at the begining. This path must be the same in the models subfolder of the addons (path and filename).

WebStorm test shortcut

Does anyone know why the shortcut to go to the tests for a given class (cmd+shift+t) doesn't work in WebStorm as it does in IntelliJ Idea, or how one can enable it?
Cmd+Shift+T does work in WebStorm; navigation is based on test names (i.e. marking folder as test root won't help here), e.g. performing Navigate | Test inside a file named My.js will navigate you to MySpec.js file.
Patterns are hardcoded to *Spec.js, *_spec.js, *-spec.js (+same patterns with "test" instead of "spec"). Note that if the file extensions differ (jsx > js), it won't work..
We have a feature request for making patterns configurable, WEB-29053; please feel free to vote for it
You need to mark the root test folder as such, you can do this by marking it by right clicking, "Mark Directory as->Test Sources Root" as below:
Or alternatively by the project preferences->directories as below:
After this one should be able to navigate between tests and their source using the cmd+shift+t shortcut.

Open a download Link , rename file and close webbrowser in Python

First off, sorry for the lack of code; verbiage is the only thing that I can think of using to describe the problem
I have a link which when I run it using:
webbrowser.open('http://www.MyLink&ticker=IBM')
automatically downloads IBM data for me. The file is automatically named download.csv
The next time I run this it tries to use the same name and therefore I get a file download(1).csv and so on.
There are 2 things I wish to accomplish.
Open the file download.csv and rename it ticker_Date.csv where ticker would be IBM or GE, etc and date is the previous biz day. This way I avoid file names download(1) download(2) etc and can actually have the file name associated with the ticker (IBM for example) and the trade date the data is from
Not open 20 web browser pages if I request 20 different tickers by closing the webbrowser after the download is complete.
I tried:
with urllib.request.urlopen(url) as response, open(file_name, 'wb') as out_file:
shutil.copyfileobj(response, out_file)
I don't seem to be able to get this to work. To be clear, when I enter the url a download automatically takes place. All of the resources I have seen have referenced "downloading" a file with a "file_Name", but this is automatically done in my case. I don't have a file name per-say
thanks for any help

Cakephp Upload Plugin - Saving Custom Path in DIR Field

I am using the https://github.com/josegonzalez/cakephp-upload
'pathMethod' => 'primaryKey'.
And the below path
'path' => '{ROOT}webroot{DS}files{DS}upload{DS}{model}{DS}{field}{DS}',
So, I am stuck at a point where in I want to save the DIR with a more elaborate information than just the primaryKey ID in DIR field
eg DIR field to be saved as "upload/organization/logo/1", currently its just saves "1"
I have gone though the documentation several times, but unable to understand about how to solve the above situation. Please help through with this.
Why want this feature, when everything is happening auto-magically, using only dir field in the view helps a lot, to link the file.
Thanks.
With the current code base, I believe the only solution you have at your disposal is to use the pathMethod of 'flat', use the 'handleUploadedFileCallback' property and manage the handling of directory creation and file movement (from TMP to 'path') on your own...and then also save the 'dir' property of your model (if you're saving that) within that callback (or afterSave) as well. Using 'pathMethod' => 'flat' removes the automatic saving of the file's location.
According to GitHub tickets, it seems that Jose might have plans to implement this feature in the future, but it's a "WIP" (Work in Progress).

Difficulty with filename and filemime when using Migrate module

I am using the Drupal 7 Migrate module to create a series of nodes from JPG and EPS files. I can get them to import just fine. But I notice that when I am done importing them if I look at the nodes it creates, none of the attached filefield and thumbnail files contain filename information.
Upon inspecting the file_managed table I see that both the filename and filemime fields are empty for ONLY the files that I attached via the migrate module. This also creates an issue with downloading the files.
Now I think the problem has to do with the fact that I am using "file_link" instead of "file_copy" as the file operation I specify. The problem is I am importing around 2TB (thats Terabytes) of image files. We had to put in a special request with Rackspace just to get access to that much disk space on our server. So I can't go around copying from one directory to the next because of space issues. So "file_link" seems like the obvious choice.
Now you probably want to see how I am doing this exactly, so here is the code snippet:
$jpg_arguments = MigrateFileFieldHandler::arguments(NULL,
'file_link', FILE_EXISTS_RENAME, 'en', array('source_field' => 'jpg_name'),
array('source_field' => 'jpg_filename'), array('source_field' => 'jpg_filename'));
$this->addFieldMapping('field_image', 'jpg_uri')
->arguments($jpg_arguments);
As you can see I am specifying no base path (just like the beer.inc example file does). I have set file_link, the language, and the source fields for the description, title, and alt.
It is able to generate thumbnails from the JPGs. But still missing those columns of data in the db table. I traced through the functions the best I could but I don't see what is causing this. I tried running the uri in the table through the functions that generate the filename and the filemime and they output just fine. It is like something is removing just those segments of data.
Does anyone have any idea what this could be? I am using the Drupal 7 Migrate module version 2.2. It is running on Drupal 7.8.
Thanks,
Patrick
Ok, so I have found the answer to yet another question of mine. This is actually an issue with the migrate module itself. The issue is documented here. I will be repealing this bounty (as soon as I figure out how).

Resources