~ubuntu-branches/ubuntu/wily/padre/wily

« back to all changes in this revision

Viewing changes to lib/Padre/Autosave.pm

  • Committer: Bazaar Package Importer
  • Author(s): Damyan Ivanov
  • Date: 2009-08-12 14:44:55 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20090812144455-yvk90oa92khfcnls
Tags: 0.42-1
* New Upstream Version
  + add explicit dependency on libtest-simple-perl (>= 0.88)
  + rules: use dh --with quilt (and bump quilt build-dependency to 0.46-7)
  + rules: no need to re-generate .mo files from .po. Upstream does it now
  + copyright: describe share/icons/padre/16x16/logo.png
    - describe share/icons/padre/16x16/toggle-comments.png
    - Padre license is the same as Perl (i.e. not Perl 5)
    - update list of copright holders
    - also list translators
  + drop libtest-most-perl from build-dependencies
  + add liblocale-msgfmt-perl to build-dependencies
  + add libcapture-tiny-perl to (build-)dependencies
  + add libfile-remove-perl (>= 1.42) to (build-)dependencies
  + drop libmodule-inspector-perl from (build-)dependencies
  + add libppix-editortools-perl to (build-)dependencies
  + add libparse-exuberantctags-perl to (build-)dependencies
  + patches:
    - drop lower-wx-requirement-to-2.8.7.patch and replace it with
      SKIP_WXWIDGETS_VERSION_CHECK=1 when configuring
      adjust README.debian accordingly
    - refresh disable-tcp-server.patch
    - drop don't-require-new-file-path.patch (applied upstream)
    - rework fix-pod2-errors.patch (new release, new errors :))
* add fix-perl-interpreter-path.patch fixing the path to the perl interpreter
  in three examples (thanks lintian)
* add more lintian overrides about script-not-executable for scripts that are
  treated as examples/templates
* add fix-whatis.patch fixing the whatis entry of Padre::Wx
* add menu and .desktop file

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
use strict;
4
4
use warnings;
5
5
 
6
 
our $VERSION = '0.36';
 
6
our $VERSION = '0.42';
7
7
 
8
8
=head1 NAME
9
9
 
36
36
metadata and autocleanup.
37
37
 
38
38
Besides the content of the file we need to save some meta data:
39
 
- path to the file will be the unique identifyer
 
39
- path to the file will be the unique identifier
40
40
- timestamp
41
41
- type of save (initial, autosave, usersave, external)
42
42
 
114
114
        # Create the autosave table
115
115
        $class->do(<<'END_SQL') unless $class->table_exists('autosave');
116
116
CREATE TABLE autosave (
117
 
        path        VARCHAR(1024) PRIMARY KEY,
 
117
        id          INTEGER PRIMARY KEY AUTOINCREMENT,
 
118
        path        VARCHAR(1024),
118
119
        timestamp   VARCHAR(255),
119
120
        type        VARCHAR(255),
120
121
        content     BLOB
121
 
)
 
122
);
 
123
CREATE INDEX file_path ON autosave (path);
122
124
END_SQL
123
125
 
124
126
}
133
135
}
134
136
 
135
137
sub save_file {
136
 
        my ( $self, $path, $type, $content, $timestamp ) = @_;
 
138
        my ( $self, $path, $type, $content ) = @_;
137
139
 
138
 
        Carp::croak("Missing type") if not defined $type;
 
140
        Carp::croak("Missing type")         if not defined $type;
139
141
        Carp::croak("Invalid type '$type'") if not grep { $type eq $_ } $self->types;
140
 
        $timestamp ||= time;
 
142
        Carp::croak("Missing file")         if not defined $path;
141
143
        $self->do(
142
144
                'INSERT INTO autosave ( path, timestamp, type, content ) values ( ?, ?, ?, ?)',
143
 
                {}, $path, $timestamp, $type, $content,
 
145
                {}, $path, time(), $type, $content,
144
146
        );
145
147
 
146
148
        return;
147
149
}
148
150
 
 
151
sub list_revisions {
 
152
        my ( $self, $path ) = @_;
 
153
 
 
154
        Carp::croak("Missing file") if not defined $path;
 
155
        return $self->selectall_arrayref(
 
156
                "SELECT id, timestamp, type FROM autosave WHERE path=? ORDER BY id",
 
157
                undef, $path
 
158
        );
 
159
}
 
160
 
149
161
1;
150
162
 
151
163
# Copyright 2008-2009 The Padre development team as listed in Padre.pm.