Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2234)

Unified Diff: lib/Brackup/DecryptedFile.pm

Issue 52065: gc and encrypted metafiles Base URL: http://brackup.googlecode.com/svn/trunk/
Patch Set: take two... Created 14 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/Brackup/Decrypt.pm ('k') | lib/Brackup/Restore.pm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/Brackup/DecryptedFile.pm
===================================================================
--- lib/Brackup/DecryptedFile.pm (revision 0)
+++ lib/Brackup/DecryptedFile.pm (revision 0)
@@ -0,0 +1,34 @@
+package Brackup::DecryptedFile;
+
+use strict;
+use warnings;
+use Carp qw(croak);
+use Brackup::Decrypt;
+
+sub new {
+ my ($class, %opts) = @_;
+ my $self = bless {}, $class;
+
+ $self->{original_file} = delete $opts{filename}; # filename we're restoring from
+
+ die "File $self->{original_file} does not exist"
+ unless $self->{original_file} && -f $self->{original_file};
+ croak("Unknown options: " . join(', ', keys %opts)) if %opts;
+
+ # decrypted_file might be undef if no decryption was needed.
+ $self->{decrypted_file} = Brackup::Decrypt::decrypt_file_if_needed($self->{original_file});
+
+ return $self;
+}
+
+sub name {
+ my $self = shift;
+ return $self->{decrypted_file} || $self->{original_file};
+}
+
+sub DESTROY {
+ my $self = shift;
+ unlink(grep { $_ } ($self->{decrypted_file}));
+}
+
+1;
« no previous file with comments | « lib/Brackup/Decrypt.pm ('k') | lib/Brackup/Restore.pm » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b