On Parse.com, in a Class I have one column which is AUDIO data.
My question is:
Does the AUDIO data gets completely removed automatically when I delete the ROW (using a Cloud function)?
Or do I need to do something special (before or after) to clean off the AUDIO data?
To make the context clearer here is the kind of code I use to upload the sound data:
PFFile *parse_Sound;
NSData *soundData = [NSData dataWithContentsOfURL:myURL];
parse_Sound = [PFFile fileWithName:#"VOICE"
data:soundData];
[parse_Sound saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
……….
}];
and later:
parse_Object = [PFObject objectWithClassName:#"PeraSentence"];
[parse_Object setObject:parse_Sound forKey:#"AUDIO"];
………
When you delete a row, the files are not deleted. You need to go in Settings > General and click to "Clean Up Files" button.
All files are not referred by pointer in your database are removed.
As you know, files can be referenced to from file-type columns in your
objects. They can be pointed to in this manner by one or many
different objects, and so they are not deleted automatically when any
of the objects that refer to them are deleted. The Clean Up job will
delete any files that have no such references to them.
As a safeguard, any files uploaded in the previous hour won't be
deleted, regardless of how many objects point to them. This provides a
grace period to avoid deleting a file that was recently uploaded but
your app has not added a reference to it.
This Clean Up job should be used carefully. If your app is not using
the file-type column to refer to files, and instead is copying the CDN
URL to a string-type column, this will not count as a reference and
the file will be deleted if it has no other file-type pointers to it.
Source: https://parse.com/questions/clean-up-files
It depends how you stored it in Parse. If you stored it as data in a column then it lives and dies with the row. Delete the row you delete the data.
If instead you used a Parse File then your row only contains a pointer to the file, delete the row and you delete the pointer, but the file is still there. Same concept as pointers to other records.
Related
I'm creating an application in which users can create notes that are displayed in a grid. When a note is created, a corresponding text file is also created. When a user opens the application, the application reads the directory of note files, retrieves the content of each note file, and then displays it in the grid.
The idea is to make the grid of notes rearrangeable via drag-and-drop.
I've never done anything this before, so I'm struggling to devise an efficient way to cache or remember the order in which the user has arranged the notes. I thought of storing the position of each note in the filename itself.
1_note3.txt
2_note7.txt
3_note4.txt
4_note2.txt
5_note6.txt
6_note8.txt
7_note5.txt
8_note1.txt
This doesn't seem like a good approach since, anytime the the notes are rearranged, I'll have to rename a bunch of the files. For example, say the user creates a new note — which would be inserted as the first child of the grid for the sake of user experience — all of the filenames would have to be renamed.
1_note9.txt
2_note3.txt
3_note7.txt
4_note4.txt
5_note2.txt
6_note6.txt
7_note8.txt
8_note5.txt
9_note1.txt
Further, say a user now rearranges the notes by moving the first note to the fourth position in the top row. I'd now have to rename that file and all of the following files.
2_note3.txt
3_note7.txt
4_note4.txt
5_note9.txt
6_note2.txt
7_note6.txt
8_note8.txt
9_note5.txt
10_note1.txt
I could also store the order or arrangement in a separate file, and exclusively manipulate the content of this file instead of the actual filenames.
arrangement.txt
note3.txt
note7.txt
note4.txt
...
Although this may be superior to the last approach, it also doesn't seem that great since there is still additional overhead. For instance, when the application is launched, I'll first have to read that file in order to obtain the user arrangement before sorting files accordingly.
Does anybody have any experience implementing something like this? Is there a better way to go about it?
You may like to maintain state of your note grid in a key-value map data structure. you can cache this map in-memory or persist it in a separate file. This key-value map will store note grid data where "Key" will have position order in the grid and "Value" will have name of the corresponding text file. In case notes are rearranged you only need to update value of two keys.
I'm using Ensembles in this project where I have different user-groups stored under separate directories. I've built this more or less copying the example app, Idiomatic's sync-manager.
Initialising the CDECloudFileSystem i do this:
newSystem = [[CDECloudKitFileSystem alloc] initWithUbiquityContainerIdentifier:[CKContainer defaultContainer].containerIdentifier
rootDirectory:directoryString usePublicDatabase:YES];
Where the directoryString is the global ID of the current user-group.
Now I'd like to be able to switch between groups, letting the users only have their group's data locally on the device.
My idea how to solve this is to change user-group by selecting it from a table view (a bunch of CKRecords with the group's name and global ID corresponding the Ensembles/Core Data objects), deleeching to remove old data in case the user is logged into a different group, and then leeching to get the data of the selected group.
Would this method work, will the old data be deleted locally on a deleech or are there better ways to go about this?
I think your plan sounds OK. The main challenge will be how you are going to manage how a user joins a particular group.
Note also that the public DB is entirely public. Something that may be of interest is that there is now an option for encrypting data with a password. It has just been added to github. You could use a password to conceal the data of each group.
Deleeching just deletes the cache of sync data. It does not remove your local persistent store data. If you leech again, the local data would import again. If you don't want that, you will have to remove the persistent store, delete the store files, and add back an empty store.
You should also check the leech options. There is one that assumes all data is in the cloud, and that should be more efficient for your case.
I know there are a lot of questions about the delete rules of Core Data relationships, but I didn't find an answer to my "problem".
In my Core Data Model, I have a many-to-many relationship between the CDMTransaction and CDMTransactionTag entities (CDMTransaction.tags <<->> CDMTransactionTag.transactions). Each transaction can be linked to zero, one or more tag, and then every tag can be linked to one or more transaction (or zero, but this doesn't make sense to keep it, and this is what I'm working on).
So when I delete a tag (will a "Nullify" delete rule), it is removed from the transactions that had this tag. This is OK.
But what I would like to do, is when I delete a transaction and its linked tag(s) remained unused (CDMTransactionTag.transactions.#count == 0), this/these tag(s) should be also deleted.
Can I set a "Cascade" rule for the CDMTransaction entity? It would delete all its linked tags, even if they are still linked to other transactions, no?
Am I forced to do that programmatically?
Thanks!
Edit: in fact, I just would like to delete the CDMTransactionTag instances when their .transactions.#count == 0 (so it shouldn't be checked only when I delete some transactions, but also when I change the tags of a transaction).
Don't know if you are still pursuing to a solution within your desired scope.
I'm dealing with similar issues and would like to share my findings so far:
Among the delete rules, only cascade will delete the object(s) (e.g. in your question: your *Tag entity instance(s)) at the relationship (1st) destination,
it does delete the destination objects even if they are "still linked to other transactions" unless...,
unless the "linked to other transactions" is a relationship(2nd) with delete rule of deny,
because only deny rule can prevent source object to be deleted when there is at least one object at the relationship(2nd) destination among the rules; and,
the delete rules are to specify what should happen if AN ATTEMPT is made to delete the source object, (i.e. the moment just right before the possible source object deletion occurs).
I have not yet tested the above design for the similar issues but I will try and post the result later if I may see some ongoing activities to the post.
I have an interesting (well to me anyways) problem here. I am doing a code based mass upload of documents into a SharePoint library with a twist. The twist is that the file's last modified date needs to be maintained in the item properties after the upload.
The file details are determined from a csv file that contains the path and the metatdata that needs to be attached to the library items as the library is based on a custom content type with metadata fields.
The problem I am having is that the modified date is only being maintained with the last file uploaded. All other files indicate the upload time. I did a little more digging and turned on version control. It turns out that files that I have uploaded are being modified multiple times as they have multiple minor versions applied to them, while the final file being uploaded has only one. For example. I am uploading 6 files to test out the process. The last file that is uploaded is sitting at version .1, the other files range from version .6 to .8 to .12. All files you can see had the correct modified date at the initial setup upon upload, but immediately a change occurred that modified the date and incremented the new modified date.
Version History:
I have tried an date using the following methods:
spFile.Item.UpdateOverwriteVersion()
item.Update() (when accessing items as a list and not from a file object
spFile.Item.SystemUpdate(false)
None of these updates seem to do what I wish.
Try
Using site As SPSite = New SPSite(siteURL)
Using Web As SPWeb = site.OpenWeb()
Dim itemList As SPList = Web.Lists("DM Import Test")
For Each item As SPListItem In itemList.Items
If item.Name = importFile.fileName Then
item(SPBuiltInFieldId.Modified) = importFile.modifiedDate
item.Update()
End If
Next
End Using
End Using
importFile is just a custom object with the properties I need.
Please let me know if you have come across this and if you happen to have a resolution.
I also tried building the entry with:
spFile = uploadFolder.Files.Add(Path.GetFileName(importFile.FullPath), fileStream, createdBy, modifiedBy, created, modified)
Where the uploadFolder was an folder object of the libary.
Thank you.
I'm trying to figure out how ExpressionEngine deletes entries.
I've written an log-like extension that tracks when an entry is created. When I delete an entry through EE's edit section, the entry is also removed from the separate table I created for my extension.
How does EE know to delete the row from my table when the entry is removed? One of the columns in my table is `entry_id`. It would seem like EE automatically checks all tables for a entry_id column and if the value matches the value being deleted, the row is removed. Can anyone confirm this?
It would explain why I didn't have to make a function that hooks into delete_entries_loop to achieve this functionality.
That's very odd. That behavior would be insane if it was indeed the case!
Looking at the delete_entry() method of the Channel Entries API, the deletions are very specifically limited to:
channel_titles
channel_data
category_posts
relationships
comments
comment_subscriptions
channel_entries_autosave
entry_versioning
The Channel Fields API is also called, to let fieldtypes delete what they need to from their own database tables based on the entry being deleted, but only if they contain a delete() method.
I'd suggest turning on the output profiler, then running the deletion routine to see what queries are being run.