Update the X-Delete-After time on an existing OpenStack Swift file? - openstack-swift

I'm using OpenStack Swift as a cache, and using X-Delete-After to make sure that old data are deleted.
How can I update or remove the X-Delete-After value for an existing file (without re-uploading it)?

The general answer is to POST the updated metadata (including the new value for x-delete-after) to the object. Remember you need to POST the entire contents of the object metadata, not just the part you want updated.
If you've got "fast post" enabled (the post_as_copy=False proxy config setting and the default), then the metadata will be updated without copying the file contents on the server-side.
If you don't have fast post enabled, it works the same way, but on the sever side it will end up doing a COPY. This is internal to the cluster, and the object data is not sent to the client.

Related

how to find what looks at a content Database in SharePoint 2010

There is plenty of documentation out there for looking up what content DB a site collection uses in SharePoint. However, I'm looking for the reverse. I have a specific DB, and I need to know where (what URL's) it's content is referenced or displayed.
We have a DB that has been partially corrupted and in need of restoring. It appears the only clean backup we have of it is relatively old. However, at first glance the library we know to be using it is lightly used. There has been no new content added to it since our backup was taken.
I am looking for a way to confirm that restoring from this backup wont unknowingly overwrite some critical data somewhere else.
In doing more digging, I did find another SO post that was able to get me the information I needed.
How to see all site collections in a specific content DB
-ContentDatabase contentdbname | select url, #{label="Size";Expression={$_.usage.storage}}
In navigating to the returned URL, I found recently added data. So that now rules out the restore.

Checking for a new version of a plist on my server

I've experimented with several ways on seeing if I need to update my user's UITableView data source only if the server one is newer. Over the past few years I've done these scenarios: 1: Having a seperate .txt file with a character as the version # then simply comparing them through code and downloading the new .plist, then saving that .txt to the user's NSDocumentDirectory along with the .plist to compare again in the future, and 2: Actually checking the server's file modification date, which worked even better, as there was no .txt file to download along with the .plist (the less stuff to download the better)
But, now I want to try a different way to account for the fact that I ship a .plist file in the App Bundle. Since the .plist file creation date is always later then the server date for new users, they don't get the new .plist file, whereas older users of the app get the new file. Sure, on the first app launch I could grab the server's modification date and overwrite the app's since I copy it from the main bundle to the NSDocumentDirectory, but I don't think I want to go that route, as I've never liked checking launch counts.
Basically, it needs to continue to be lightweight in network request time and be reliable like it's been for me. I was thinking about creating a version # key in my .plist and simply comparing that with the local .plist, but I highly doubt this will be as lightweight, as I would have to download the whole .plist into an NSDictionary first before I can compare the key values.
I'm really sorry this post is long, and I appreciate your help!
Why not ship the app with out the data_source.plist file and download it on first launch, or any other time it does not exist on disk (you never know). After that, you could send a HEAD request and check the modification date (maybe even the e-tag), and download as necessary.
UPDATE:
Depending on how much control you have over the server, you could add a hash of the file to the response headers (as mentioned in the comments: MD5,SHA*) along side Last-Modified.
You could add the data_source.plist to the bundle at build time, along with last_modified.plist where you can set the hash, last modified, and any other meta data you want, as starting point.
Checking for updates could look something like:
Send HEAD request for http://server.com/data_source.plist
Pull Last-Modified (and hash if you can send it) from the response headers
Validate against corresponding values in last_modifed.plist
Download updated data_source.plist if needed
If the download was successful, update last_modifed.plist with new meta data (last modified and has, be sure pull this from actual download response headers).
This way, the user has something to start with, and the app can download the resource when needed.
The advantage of a HEAD request is it is light weight since there is no message body, but returns the same response headers as a GET request. It is a common method to check if a resource has been updated. The trick with your scenario is to get a starting point onto the device at build time.

Auto fetch data from website iOS/iPhone Programming

I wanted to auto fetch data(gold price) from a website and update a variable. Do i have to load the whole .html file in a string and find the price? Is there any other way? Even if I updated the variable, how do i save it, so it retains it's updated value(price)?
Do i have to load the whole .html file
in a string and find the price?
Yes
Is there any other way?
Only if the web site also provides an API that gives you access to just the data you need.
Even if I updated the variable, how do
i save it, so it retains it's updated
value(price)?
A variable will keep it's value until you change it. However if you want to preserve it even when the user quits your app, so that it starts again from the same value, you could save it in NSUserDefaults for example.
Do be aware however, that the data is almost certainly copyright, you can't just scrape data from a website and publish an app based on that data without considering the legal perspective. Price data is normally owned by the exchange and you will need a license to re-publish it.

Does updating your application delete files?

I wrote a game that I plan on updating soon. The game generates a scoreboard when the application starts, if there is no scoreboard file present.
If people update to my latest version, will the scoreboard file (that's generated by the code itself, not a file that comes preloaded in the app) be deleted?
If so, is there any way to avoid this without any coding previously required?
The updated version of your app will simply replace the existing version's bundle - any files you've written to your app's document area will remain intact.
As such, you simply need to check for the presence of the file within your app's document area as per usual and write a "new" version if none exists.
If the file is within your applications bundle, it will be deleted. Files saved with Core Data and NSUserDefaults will not. I've never personally written a file to the disk, so I don't know where the default write point is. You'll have to find this out yourself.
Happy coding,
Zane

sqlite DB to-do during iphone app update

I have some general questions about iphone app updates that involves sqlite db.
With the new update does the existing sqlite db get overwritten with a copy of the new one?
If the update doesn't involve any schema changes then the user should be able to reuse the existing database with their saved data, right? (if the existing database doesn't get overwritten from 1 above )
If there are some schema changes, what's the best way to transfer data from the old database into the new one? Can some one please give me guidelines and sample code?
Only files inside the app bundle are replaced. If the database file is in your app's Documents directory, it will not be replaced. (Note that if you change files inside your app bundle, the code signature will no longer be valid, and the app will not launch. So unless you are using a read-only database, it would have to be in the Documents directory.)
Yes.
What's best depends on the data. You're not going to find sample code for such a generic question. First, you need to detect that your app is running with an old DB version. Then you need to upgrade it.
To check versions:
You could use a different file name for the new schema. If Version2.db does not exist but Version1.db does, do an upgrade.
You could embed a schema version in your database. I have a table called metadata with a name and value column. I use that to store some general values, including a dataversion number. I check that number when I open the database, and if it is less than the current version, I do an upgrade.
Instead of creating a table, you could also use sqlite's built-in user_version pragma to check and store a version number.
You could check the table structure directly: look for the existence of a column or table.
To upgrade:
You could upgrade in place by using a series of SQL commands. You could even store a SQL file inside your app bundle as a resource and simply pass it along to sqlite3_exec to do all the work. (Do this inside a transaction, in case there is a problem!)
You could upgrade by copying data from one database file to a new one.
If your upgrade may run a long time (more than one second), you should display an upgrading screen, to explain to the user what is going on.
1) The database file isn't stored as part of the app bundle so no, it won't get automatically overwritten.
2) Yes - all their data will be saved. In fact, the database won't get touched at all by the update.
3) This is the tricky one - read this fantastically interesting document - especially the part on lightweight migration - if your schema changes are small and follow a certain set of rules, they will happen automatically and the user won't notice. however, if ther are major changes to the schema you will have to write your own migration code (that's in that links as well)
I've always managed to get away with running lightweight migrations myself - it's by far easier than doing it yourself.
What I do is that I create a working copy of the database in the Documents directory. The main copy comes with the bundle. When I update the app I then have the option to make a new copy over the working copy, or leave it.